while
1초기식
while(2조건식){
3반복처리구문
4증감식
}
// 1 2 3 4 5 6 7 8 9 10 출력
int i = 1;
while(i <= 10) {
System.out.println(i);
i++;
}
int i = 1;
while(i++ <= 100) {
if(i % 2 != 0) {
continue;
}
System.out.println(i);
}
do ... while
do{일단 실행}while(조건식){반복처리구문}
public void test() {
Scanner sc = new Scanner(System.in);
char yn = ' ';
do {
System.out.println("--- 시작 ---");
System.out.println("--- 끝 ---");
System.out.println("더 하시겠습니까?(y/n) : ");
yn = sc.next().toLowerCase().charAt(0);
} while(yn == 'y');
System.out.println("종료");
}