why use continue ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why use continue ?

int x=10; while(x>5){ system.out.println("hello") if(x==30){ continue; } x++; }

5th Jun 2017, 8:43 PM
hussein
2 Answers
0
continue is used to restart the loop from the beginning. say you take input and want to check if it is an integer while { input=get input; if(input != int){ print: "Choose only int!"; continue; } else { print: "Good Job"; break; } } If the input isn't an int, it would instruct user to enter an int and restart the loop asking for input again.
5th Jun 2017, 8:49 PM
LordHill
LordHill - avatar
0
thx ❤
5th Jun 2017, 8:51 PM
hussein