자바 기본 다루기 동일한 작업을 반복 처리하는 반복문

Click here to load reader

download 자바  기본 다루기 동일한  작업을 반복 처리하는 반복문

of 40

description

자바 기본 다루기 동일한 작업을 반복 처리하는 반복문. 6 장 동일한 작업을 반복 처리하는 반복문. 지정된 반복 횟수만큼 수행하는 for 문 조건을 먼저 검사하는 while 문 조건을 나중에 검사하는 do~while 문. 1. 지정된 반복 횟수만큼 수행하는 for 문. 1. 지정된 반복 횟수만큼 수행하는 for 문. [ 동작 원리 ] ① 처음에 초기값 실행 ② 조건식을 평가하여 참이면 문장 1~ 문장 n 까지 실행 ③ 증감식 실행 - PowerPoint PPT Presentation

Transcript of 자바 기본 다루기 동일한 작업을 반복 처리하는 반복문

2 - 6

6 for while do~while 1. for for(; ; ){1;2;...n;} ;1. forfor(; ; ){1;2;...n;};[ ] 1~n 1~n 1. for System.out.println("Hello World!");System.out.println("Hello World!");System.out.println("Hello World!");System.out.println("Hello World!");System.out.println("Hello World!");System.out.println("Hello World!");System.out.println("Hello World!");System.out.println("Hello World!");System.out.println("Hello World!");System.out.println("Hello World!");int i;for(i=1; i=1; i--) 22: System.out.print(" " + i ); 23: System.out.println("\n ------------------------- >> " ); 24: } 25:} 2 01:class For04 { 02: public static void main(String[] args) { 03: int i; // 04: int a=2; // , 2 05: 06: System.out.println(" " ); 07: for(i=1; i 3240 1 ~ 90 -> 4095 1 ~ 100 -> 5050

3. 1 100 10 . 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 4. .

5. (*) .

6. A I . ABCDE FGH I

7. . public class ForEx03 { public static void main( String[] argv ) { for (int i =0; i