2015-04-20 15:36:01 -07:00
|
|
|
|
//: control/WhileTest.java
|
2015-05-29 14:18:51 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
2015-04-20 15:36:01 -07:00
|
|
|
|
// Demonstrates the while loop.
|
2015-06-03 11:41:10 -07:00
|
|
|
|
// {OutputFirstAndLast: 5 Lines}
|
2015-04-20 15:36:01 -07:00
|
|
|
|
|
|
|
|
|
public class WhileTest {
|
|
|
|
|
static boolean condition() {
|
|
|
|
|
boolean result = Math.random() < 0.99;
|
|
|
|
|
System.out.print(result + ", ");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
while(condition())
|
|
|
|
|
System.out.println("Inside 'while'");
|
|
|
|
|
System.out.println("Exited 'while'");
|
|
|
|
|
}
|
2015-06-03 11:41:10 -07:00
|
|
|
|
} ///:~
|