for(초기화, 표현식, 증가)
for(int i = 0 ; i < 10 ; i++)출력:
System.out.println(i);
0세 가지 for 표현식은 선택 사항입니다. 무한 루프는 다음과 같이 생성됩니다.
1
2
3
4
5
6
7
8
9
for( ; ; )
//instructions
String[] t = {"a","b","c","d","e","f","g","h","i","j","k"};출력:
for(문자열 s:t)
System.out.println(들);
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;출력:
do{
System.out.println(nb++);
}동안(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.