자바/자바 실습

14 While 반복문

hyeonseong 2022. 7. 28. 14:17

While문

  • While문은 조건식이 참이면 문장들을 반복적으로 실행한다.

 

형태

while(조건식){

반복문

}

  • 0~9까지 출력하는 while문
package ex06;

public class GugudanEx03 {

	public static void main(String[] args) {
		// Daemon: 멈추지 않는 프로그램
		int i =0;
		while(i < 10) { // 조건식
			System.out.println(i);//반복 실행문
			i++;
		}
		
	}

}

 

결과