IT공부방
[알고리즘] The for Statement (for 명령문)
saltdoll
2010. 6. 4. 20:21
반응형
출차: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html
기본이 되는 for문법 설명입니다.
<< for Statement(명령문) >>
<< 예제 >>
class ForDemo {
public static void main(String[] args){
for(int i=1; i<11; i++){
System.out.println("Count is: " + i);
}
}
}
The output of this program is:
<< 응용편 >>
기본이 되는 for문법 설명입니다.
<< for Statement(명령문) >>
for (initialization; termination; increment) {
statement(s)
}
termination : 부분이 true면 계속 반복 실행되며, false면 실행중지 됩니다.statement(s)
}
<< 예제 >>
class ForDemo {
public static void main(String[] args){
for(int i=1; i<11; i++){
System.out.println("Count is: " + i);
}
}
}
The output of this program is:
Count is: 1 Count is: 2 Count is: 3 Count is: 4 Count is: 5 Count is: 6 Count is: 7 Count is: 8 Count is: 9 Count is: 10
<< 응용편 >>
// 두가지 조건에 맞으면 종료~~!!
for(int i = 0; (i < recentboard.size() && i < 1); i++) {
}
for(int i = 0; (i < recentboard.size() && i < 1); i++) {
}
반응형