-
[8] whileDevelpment/Java Sample Source 2020. 9. 13. 21:27
while
12345678910111213141516171819202122232425package control_statement03;public class While01{public static void main(String[] args){// while문 : 선 비교 후 처리int nNum = 1;while(nNum <= 5) // (조건식){// 조건식이 참일때 실행되는 영역System.out.println(nNum);nNum++;}while(true){System.out.println("Test");}//System.out.println("감사합니다.");}}cs 실행결과
Test
Test
Test
Test
Test
Test
...(생략)
while 2
123456789101112131415161718192021package control_statement03;public class While02{public static void main(String[] args){int nNum = 1;int nNum2 = 1;while(nNum <= 3){System.out.printf("%d = ", nNum++);for(int i = 1; i <= 5; i++){System.out.printf("%d ", nNum2++);}System.out.println();}}}cs 실행결과
1 = 1 2 3 4 5
2 = 6 7 8 9 10
3 = 11 12 13 14 15
'Develpment > Java Sample Source' 카테고리의 다른 글
[10] break, label (0) 2020.09.13 [9] do-while (0) 2020.09.13 [7] for - multi (0) 2020.09.13 [6] for - single (0) 2020.09.13 [5] switch (0) 2020.09.13