CATEGORII DOCUMENTE |
Asp | Autocad | C | Dot net | Excel | Fox pro | Html | Java |
Linux | Mathcad | Photoshop | Php | Sql | Visual studio | Windows | Xml |
while, do-while and for control looping and are sometimes classified as iteration statements. A statement repeats until the controlling Boolean-expression evaluates to false. The form for a while loop is
while(Boolean-expression statement
The Boolean-expression is evaluated once at the beginning of the loop and again before each further iteration of the statement.
Here's a simple example that generates random numbers until a particular condition is met:
//: WhileTest.java
// Demonstrates the while loop
public class WhileTest
}
This uses the static method random( ) in the Math library, which generates a double value between 0 and 1. (It includes 0, but not 1.) The conditional expression for the while says "keep doing this loop until the number is 0.99 or greater." Each time you run this program you'll get a different-sized list of numbers.
Politica de confidentialitate | Termeni si conditii de utilizare |
Vizualizari: 561
Importanta:
Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved