java/코드 리뷰

4. control - (5) ForDemo5 (For문)

Astaroth아스 2020. 3. 20. 12:01
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package control;
 
public class ForDemo5 {
    public static void main(String[] args) {
        // 중첩 for문
        for (int i=1; i<=3; i++) {
            System.out.println("i값 : " + i);
            
            for (int j=1; j<=5; j++) {
                if ( j>= 3) {
                    break// 중첩 for문에서 break는 해당 for문을 탈출한다
                            // 바깥족 for문은 영향을 받지 않는다
                }
                System.out.println("i값  : " + i + ", j값 : " + j);
            }
        }
        
        
    }
}