Continue statement tell the compiler to skip the following statament and continue with the next iteration
Syntax:-
continue;
Continue statement in for loop
Here continue causes the control to go to increment section(3rd section in for loop) of the loop than condition statement(2nd section in for loop).
Example:-
Java program for display odd number using continue statement
import java.util.Scanner;
class group{
public static void main(String angt[]){
Scanner data = new Scanner(System.in);
int num,i,j;
System.out.println("Enter a number");
num=data.nextInt();
for(i=1;i<=num;i++)
{
j=i%2;
if(j == 0)
continue;
else
System.out.println(i);
}
}
}
Continue statement in while and do while loop
Here continue causes the control to go to condition statement of loop.
Example:-
Java program display even number using continue statement
import java.util.Scanner;
class group{
public static void main(String angt[]){
Scanner data = new Scanner(System.in);
int num,i;
System.out.println("Enter a number");
num=data.nextInt();
i=0;
while(i<=num)
{
i++;
if((i%2)==0)
continue;
else
System.out.println(i);
}
}
}
Previous Code:-
Break statement in java
List Code:-
Java codes
Next Code:-
Goto statement(labeled break)
Java Programs:-
List of Java Programs
Syntax:-
continue;
Continue statement in for loop
Here continue causes the control to go to increment section(3rd section in for loop) of the loop than condition statement(2nd section in for loop).
Example:-
Java program for display odd number using continue statement
import java.util.Scanner;
class group{
public static void main(String angt[]){
Scanner data = new Scanner(System.in);
int num,i,j;
System.out.println("Enter a number");
num=data.nextInt();
for(i=1;i<=num;i++)
{
j=i%2;
if(j == 0)
continue;
else
System.out.println(i);
}
}
}
Continue statement in while and do while loop
Here continue causes the control to go to condition statement of loop.
Example:-
Java program display even number using continue statement
import java.util.Scanner;
class group{
public static void main(String angt[]){
Scanner data = new Scanner(System.in);
int num,i;
System.out.println("Enter a number");
num=data.nextInt();
i=0;
while(i<=num)
{
i++;
if((i%2)==0)
continue;
else
System.out.println(i);
}
}
}
Previous Code:-
Break statement in java
List Code:-
Java codes
Next Code:-
Goto statement(labeled break)
Java Programs:-
List of Java Programs
Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as
ReplyDeleteappvn
No doubt this is an excellent post I got a lot of knowledge after reading good luck. Theme of blog is excellent there is almost everything to read, Brilliant post. Website Designing Company in Delhi
ReplyDeleteNo doubt this is an excellent post I got a lot of knowledge after reading good luck. Theme of blog is excellent there is almost everything to read, Brilliant post. Website Designing Company in Delhi
ReplyDeletePositive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Energy Saving Sensors in New Delhi
ReplyDeleteManufacturer & Dealers in Energy Saving Sensor
trung tâm tư vấn du học canada vnsava
ReplyDeletecông ty tư vấn du học canada vnsava
trung tâm tư vấn du học canada vnsava uy tín
công ty tư vấn du học canada vnsava uy tín
trung tâm tư vấn du học canada vnsava tại tphcm
công ty tư vấn du học canada vnsava tại tphcm
điều kiện du học canada vnsava
chi phí du học canada vnsava
#vnsava
@vnsava
"I got a lot of knowledge after reading good luck. Theme of blog is excellent there is almost everything to read, Brilliant post"men's 3 piece suits
ReplyDelete