The break statement terminates execution of a loop. : break « Statements « SCJP






public class MainClass {
  public static void main(String[] argv) {

    for (int i = 0; i < 10; i++) {
      if (i == 5) {
        break;
      }
      System.out.println(i);

    }

  }
}
0
1
2
3
4








5.5.break
5.5.1.The break statement terminates execution of a loop.
5.5.2.You can use labels on break statements