
Usage examples of continue in JAVA:
public class test{
public static void main(String [] args){
for(int i=0;i<=10;i++){
if(i%2!=0){
continue;
}
System.out.println(i);
}
}
}continue means to interrupt this cycle and start the next one.
Combined with this code is. When i is an odd number, no printing is done, the loop ends directly and the next time starts.
(Video tutorial recommendation: java video)
Instance 2:
public class Test7 {
public static void main(String[] args) {
for(int x=0;x<5;x++){
if(x==2){
continue;
}
System.out.println(x);
}
}
}Output result:
1 3 4 5
Recommended tutorial:java introductory program
The above is the detailed content of How to use continue in java. For more information, please follow other related articles on the PHP Chinese website!