Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 MATERI PENDUKUNG JUMP Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.

Similar presentations


Presentation on theme: "1 MATERI PENDUKUNG JUMP Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0."— Presentation transcript:

1 1 MATERI PENDUKUNG JUMP Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0

2 2 The break statement The break statement will allow you to exit a loop structure before the test condition is met. Once a break statement is encountered, the loop immediately terminates, skipping any remaining code. For instance: int x = 0;

3 3 while (x < 10){ System.out.println("Looping"); x++; if (x == 5) break; else... //do something else } In this example, the loop will stop executing when x equals 5.

4 4 The continue statement The continue statement is used to skip the rest of the loop and resume execution at the next loop iteration. for ( int x = 0 ; x < 10 ; x++){ if(x == 5) continue; //go back to beginning of loop with x=6 System.out.println("Looping"); } This example will not print "Looping" if x is 5, but will continue to print for 6, 7, 8, and 9.


Download ppt "1 MATERI PENDUKUNG JUMP Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0."

Similar presentations


Ads by Google