Please see below code for Break Statement – It is used for terminating the loop in between.

				
					package practice;

public class BreakStatment {

	public static void main(String[] args) {
		for (int i = 0; i < 5; i++) {
				  if (i == 3) {
				    break;
				  }
				  System.out.println(i);
			}
		System.out.println("After break");
	}

}

				
			

Explaination –  once i become 3  , loop will break and it will print statement after loop.

Output – 

1
2
After break

Scroll to Top