GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Java-Programs/loopAndFlow/ContinueExamples.java at master · divScorp/Java-Programs Expand file tree/ Copy pathContinueExamples.javaMore file actions 59 lines (52 loc) · 1.36 KB / Copy pathContinueExamples.javaFile metadata and controls59 lines (52 loc) · 1.36 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 package loopAndFlow; public class ContinueExamples { public static void main(String[] args) { // Continue statement skips rest of the statements in the loop // and starts next iteration for (int i = 0; i < 10; i++) { if (i == 5) { continue; } System.out.print(i); } // Output is 012346789 // Not that the output does not contain 5 System.out.println(); // Continue can be used in a while also int i = 0; while (i < 10) { i++; if (i == 5) { continue; } System.out.print(i); } // Output is 1234678910 // Not that the output does not contain 5 System.out.println(); // Continue statement takes execution to next iteration of inner most // loop for (int j = 0; j < 2; j++) { for (int k = 0; k < 10; k++) { if (k == 5) { continue;// skips to next iteration of k loop } System.out.print(j + "" + k); } } // Output is 000102030406070809101112131416171819 // Not that the output does not contain 05,15 System.out.println(); // To get out of an outer for loop, label's need to be used outer: for (int j = 0; j < 2; j++) { for (int k = 0; k < 10; k++) { if (k == 5) { continue outer;// skips to next iteration of j loop } System.out.print(j + "" + k); } } // Output is 00010203041011121314 // Not that the output does not contain anything after 05 and also 15 } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |