Java examples for Language Basics:break
Count and gets to the number 12 then aborts the loop
public class Main { public static void main(String[] args) {//ww w . j a va 2s .c o m int number = 2; while (number <= 20) { if (number == 12) break; System.out.print(number + " "); number += 2; } System.out.println(); } }