Posted by
Zhullyblog
on
- Get link
- X
- Other Apps
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.
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 +" ");
}
}
}
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++;
}
}
}
Introduction to Java programming
How to declare a variable in Java
If, if..else statement in Java
Java Object Oriented Programming
Constructors in Java programming
Please share
Please share
Comments
Post a Comment