- testet
a) boolsche
Variable, wenn Wert = true
b) Ausdruck
public
class whiletest {
public static void main(String[] args) {
int testvariable=0; // Eine numerische Variable mit Startwert = 0
while (testvariable < 5)
{ //3
// wenn der Ausdruck nicht von Anfang an true ist, wird der
// Block in der Unteranweisung niemals ausgeführt
System.out.println(testvariable);
testvariable = testvariable + 1 ;
}//3
}//2
}//1
Ausgabe:
0
1
2
3
4