Records rather than Memories

[java] while 반복문 본문

Software/JAVA

[java] while 반복문

Downer 2019. 10. 15. 16:48

While 반복문

 

while(조건){ <-- 조건이 true인 동안 반복

       반복 실행 영역                                         

}

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package javatutorials.loop;
 
public class Whileloop {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int i = 0;
        // i값이 10보다 작으면 true, 크다면 false
        while (i < 10) {
            System.out.println("Let's go!!" + i);
            // i값에 1을 더한다. 반복문의 중괄호 마지막 라인데 도달하면 반복문 조건을 검사
            i++;
        }
 
    }
 
}
 
cs

다음 코드에서 i가 10보다 작은 경우에만 Let's go!! i가 출력된다.

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

[java] break, continue  (0) 2019.10.15
[java] for문  (0) 2019.10.15
논리 연산자  (0) 2019.10.15
GUIApp  (0) 2019.10.15
[java] switch문  (0) 2019.10.14
Comments