continue Statement

continue Statement
continue is used inside a loop to repeat the next iteration of the loop. When continue is executed , subsequent in the loop are not executed and control of execution goes back to the next repetition of the loop.

Example

class test
{
public static void main(String args[])
{
for(int i=1; i<=3 ; i++)
{
for(int j=0 ; j<2 ; j++)
{
if(j == 2)
continue;
System.out.println(“i : ” + i + “, j : ” + j);
}
}
}
}

Output:
i : 1, j : 0
i : 1, j : 1
i : 2, j : 0
i : 2, j : 1
i : 3, j : 0
i : 3, j : 1

Leave a Reply

Your email address will not be published. Required fields are marked *