+ 1
Why did "continue" skip more than one value?
I wrote a do while loop with "continue" in it for practice, to mele it skip one value. Here it is:. (i will jump the class and method strings). int m=3; do { if (m==5) { continue } System.out.println(m); m++; } while (m<7); As the output I obtain only a 3 and a 4, and not also the 6 I expected. Can someone explain me why?
3 Respostas
+ 3
being m=5...it is become infinite loop..if m=5,true,continue,if m=5,true continue
+ 2
You created an endless loop cause your m++ in line 7 will not be executed for m==5 because your continue is executed before.
0
Thank you I got it now.😀