Records rather than Memories

반복문의 중첩 본문

Software/JAVA

반복문의 중첩

Downer 2019. 10. 15. 17:10

반복문은 중첩이 가능하다. 

다시 말해 for문 안에 for문을 넣는 방식이다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package javatutorials.loop;
 
public class LoopDepthDemo {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        for(int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                System.out.println(i + "" + j);
            }
        }
 
    }
 
}
 
cs

i의 for문이 먼저 들어간다 이때 i의 값은 0으로 시작하고 그 안에서

j의 for문이 돌아가기 때문에 00, 01 ... 98, 99로 이어진다.

 

 

 

 

 

'Software > JAVA' 카테고리의 다른 글

Method  (0) 2019.10.16
배열  (0) 2019.10.16
[java] break, continue  (0) 2019.10.15
[java] for문  (0) 2019.10.15
[java] while 반복문  (0) 2019.10.15
Comments