while(조건식) {
조건식이 참(true)이라면 반복해서 실행할 명령문을 실행하고,
조건식이 거짓(false)이라면 while의 { } 이부분을 빠져나간다.
반복해서 실행할 명령문;
증감식;
}
2×1 = 2 3×1=3 ... 9×1=9
int jul=0, dan=1;
while(!(++jul>9)) { // 9행
while(!(++dan>9)) { // 8열
String add = (dan<9)?"\t":"\n";
System.out.print(dan+"*"+jul+"="+dan*jul+add);
} // end of while--------------
// 위의 while 문 빠져나올때 dan 의 값은 10 이다.
// 그러므로 아래와 같이 dan 의 값을 1로 초기화 해주어야 한다.
dan=1;
} // end of while----------------------
-> 2×1=2 2×2=4 ... 2×9=18
jul=0; dan=1;
while(!(++dan>9)) {
while(!(++jul>9)) {
String add = (jul<9)?"\t":"\n";
System.out.print(dan+"*"+jul+"="+dan*jul+add);
} // end of while----------
jul=0; // 위의 while 문 빠져나올때 jul 의 값은 9 이다. (초기화 필요)
} // end of while-----------
my.day07.a.While -> Main_while