Wednesday, October 5, 2016

Muhammad Akbar

Break Statement in Java-Tutorial

Break is mainly used to exit a loop. Inside a loop, when the JVM encounters a break statement, it breaks the loop and passes the control to the next statement after the loop.
This statement is mainly useful when we need to exit from an infinite loop or exit for a loop on specific condition meet.
public class BreakDemo {

 public static void main(String[] args) {

  int i = 0;
   System.out.print(i+" ");
Try It
In the above program, while(true) is an infinite loop. But, we need to print from values 1 to 10. So, when the loop encounters i==10, break comes into action and the loop breaks.
The output is: 1 2 3 4 5 6 7 8 9 10


  Continue Statement in Java

Muhammad Akbar

About Muhammad Akbar -

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :

Hello Every One thanks For Visit My site You Can Suggest any Idea About site And Related Education Information Provide me Its Best Content For you am Include in this Site And feel free contact And email now I hope This site very help full you