Continue Statement with example in Java



This video tutorial explains the continue statement in java programming.

You will learn what is the use of continue statement in loops, how to use continue statement in loops, how continue works, how to use it in loops in detail with example.


package learningJava;

public class Mango {

 public static void main(String[] args) {
  
  System.out.println("From the for  Loop");
  for(int counter = 1; counter <= 10; counter++){
   
   if( counter == 5 ){
    continue;
   }
   System.out.println(counter+" LearningLad Rocks");
   
  }
  
  System.out.println("From the while Loop");
  
  int counter2 = 1;
  while(counter2 <= 10){
   if( counter2 == 5 ){
    counter2++;
    continue;
   }
   System.out.println(counter2+" LearningLad Rocks");
   counter2++;
  }

 }

}