Site hosted by Angelfire.com: Build your free website today!
 

Break and Continue

End a loop prematurely by executing a break statement.

for (int countDown = 10; countDown >= 0; countDown--) {
      System.out.println(countDown);
      if (countDown == 3) {
        System.out.println(?ABORT?);
        break;
      }
}
System.out.println("Leap years between 1896 and 1924");
for (int year = 1896; year <= 1924; year += 4) {
     if ((year % 100) == 0) {
        continue;
     }
     System.out.println(year);
}