While Loop
As long as condition is true, statement is repeatedly executed
Example
while ( i<=100 )
{ sum += i; i++; }
- sum of integer number from 1 to 100
Switch Block
- Execution starts at the case label that matches the value on which the selection is performed and continues until the next break or the end of the switch
- If none of the case labels matches, then the default clause is executed, if it is present
Example
switch (n % 5)
{ case 0: System.out.println(“remainder 0");
case 1: System.out.println(“remainder 1");
case 2: System.out.println(“remainder 2");
default : System.out.println(“remainder 3 or 4"); }
Continue
- The continue statement transfers control to the header of the innermost enclosing loop
- The continue statement jumps immediately to the loop header, skipping the remainder of the current iteration
Example
if (n < 0)
{ System.out.println(“n is negative number!");
continue; }
'JAVA' 카테고리의 다른 글
Basic Methods of JAVA (1) (0) | 2023.12.21 |
---|---|
Introduction to JAVA (0) | 2023.12.21 |