Break Statement with example in Java



This video tutorial explains the break statement available in java programming.

You will learn what is the use of break statement, how to use break in loops in java, what is the effect of break in a nested loop, how break statement works in detail with example.



Source code for this video tutorial


package learningJava;

public class Lion {

 public static void main(String[] args) {

  int counter,counterouter = 1;
  while(counterouter <= 10){
   counter = 1;
   while( counter <= 10 ){
    System.out.println(counter);
    if( counter == 5 ){
     break;
    }
    counter++;
   }
   counterouter++;
  }
  System.out.println("anything");

 }

}


Back To Top