Understanding "continue;" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Understanding "continue;"

I am not able to understand what is the function of continue , how to use it , and the difference between continue and break. For Other People Who Are Also Confused Check The Code Pasted Below:- https://code.sololearn.com/c3Rnm9QPRgPn/?ref=app

29th Jan 2018, 11:15 AM
Alex Snyder
Alex Snyder - avatar
8 Answers
+ 16
//here is an application of using continue for example u want to print even numbers from 1 to 10 for (int a=1;a <=10;a++){ if (a%2==1) continue; else System.out.println (a); }
29th Jan 2018, 11:30 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 11
If "continue" encounters then the statement after "continue" skips for that iteration but loop cannot stop. But if "break" encounters then loop stops.
29th Jan 2018, 11:22 AM
ScOrPiOn
ScOrPiOn - avatar
+ 8
Break leaves the loop completely and executes the statements after the loop. Whereas Continue leaves the current iteration and executes with the next value in the loop. ... A continue statement is used to end the current loop iteration and return control to the loop statement.
29th Jan 2018, 11:22 AM
Scooby
Scooby - avatar
+ 6
when x=30 then its doesnt print or say ignore to print...
29th Jan 2018, 11:26 AM
Scooby
Scooby - avatar
+ 4
don't say thank you.help to another three people and tell them help other three people,small help do big impact ☺
29th Jan 2018, 11:29 AM
Scooby
Scooby - avatar
+ 2
thank you
29th Jan 2018, 11:27 AM
Alex Snyder
Alex Snyder - avatar
+ 2
Ok :)
29th Jan 2018, 11:29 AM
Alex Snyder
Alex Snyder - avatar
+ 2
@Gaurav Agarwal I used your code and it prints out odd numbers instead of even numbers. https://code.sololearn.com/c3Rnm9QPRgPn/?ref=app
29th Jan 2018, 11:37 AM
Alex Snyder
Alex Snyder - avatar