for(initialization, expression, increment)
for(int i = 0 ; i < 10 ; i++)Output:
System.out.println(i);
03 つの for 式は省略可能です。 無限ループは次のように作成されます:
1
2
3
4
5
6
7
8
9
for( ; ; )
//命令
String[] t = {"a","b","c","d","e","f","g","h","i","j","k"};Output:
for(文字列 s:t)
System.out.println(s);
a
b
c
d
e
f
g
h
i
j
k
while(expression)式の条件はブール値を評価して返します。trueの場合、while ループはブロックを実行し、式の評価が値 false.
//instructions
int nb=8;Result:
while(nb>0)
System.out.println(nb--);
8
7
6
5
4
3
2
1
do {
//bloc
}while(expression);
nb=1;Output:
do{
System.out.println(nb++);
}while(nb%10!=0);
1参照:
2
3
4
5
6
7
8
9
Please disable your ad blocker and refresh the window to use this website.