Related post

Inheritance in Java programming with example | Zhullyblog

Continue statement in Java

 

Java continue statement


CONTINUE STATEMENT IN JAVA

The continue statement is used basically within a loop control to jump immediately to the end of  statement or loop. It is used in both for loop and while and do...while loopetc.

GENERAL SYNTAX


The syntax is one of the simplest. It's just continue followed by semicolon.



continue;

 

  


Examples



Continue keyword in For loop






public class sample{

   public static void main(String args[]){

for (int x=0; x<=10; x++)

{

           if (x==8)

           {

      continue;

   }


           System.out.print(x +" ");

}

   }

}


Continue keyword using for loop in java

Result



Continue keyword in While loop


 



public class sample{

   public static void main(String args[]){

int x=0;

while (x <=10)

{

           if (x==1)

           {

       x++;

       continue;

           }

           System.out.print(x +" ");

           x++;

}

   }

}


 


Continue statement using while loop in java
Result





Comments