개발입문/JAVA

[30일코딩] 반복문

haloaround 2017. 5. 5. 13:23



WHILE / DO WHILE

This type of loop requires a single boolean condition and continues looping as long as that condition continues to be true

True or False 조건문을 만족할때까지 루프 반복을 계속한다.

WHILE 은 조건에 맞는지 전에 확인하고 루프반복을 처리한다면,
DO WHILE 은 루프반복을 처리하고, 그 후에 조건이 맞는지 확인한다.
그래서 첫번째 루프는 꼭꼭꼭 실행된다!

FOR

초기화 조건과 종료조건 사이만큼 루프 반복을 계속한다.


NESTED FOR

For 안의 For (Outer For Loop, Inner For Loop) 행렬에 이용




FOR LOOP


for (initialization; termination; increment) {

   // ...

}


initialization    starting point of iteration

termination     stopping point of iteration

increment        reaching to termination by 1



WHILE LOOP


do{

    // this will execute once

    // it will execute again each time while(condition) is true

} while(condition);