while(do while) If the conditional expression is true, the process is repeated.
while
// while
while(flag){
//processing
}
// do while
do {
//processing
} while(flag);
for Iterate processing is performed by setting initialization, repetition conditions, and updating of counter variables.
for
for(int counter = 0;counter < 5;counter++){
//processing
}
There is also an extended for statement that iterates over each element of the Collection.
Extension for
for(String str : strList){
//processing
}
break You can get out of the iterative process by using break. It is also possible to get out of the repeated nesting process by using labels together.
break
while(true){
...
break;
}
label:
while(true){
while(true){
...
break label;
}
}
continue By using continue, the subsequent processing in the iterative processing can be skipped and the processing can be performed from the next element.
continue
while(true){
...
continue;
... //Subsequent processing is skipped
}
Recommended Posts