for(int x=10; x<=40; x=x+10) { if(x == 30) { continue; } System.out.println(x); } | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

for(int x=10; x<=40; x=x+10) { if(x == 30) { continue; } System.out.println(x); }

what if use break to stop execution..

20th Aug 2017, 2:54 PM
maddila Shankar
maddila Shankar - avatar
5 Respuestas
+ 1
output with continue 10 20 40 output with break 10 20 Right ?
20th Aug 2017, 3:05 PM
Chokri ZAGROUBA
Chokri ZAGROUBA - avatar
+ 1
Sir, The difference between continue and break is simple. Continue is used to skip a value in a loop and break is used to terminate the loop prematurely. So in your segment, currently the loop runs to completion but skips value 30. Break will terminate the loop upon reaching the value 30.
20th Aug 2017, 3:08 PM
The Artist Formally Known as Jeremy
The Artist Formally Known as Jeremy - avatar
0
chokri,your answer is right
20th Aug 2017, 3:35 PM
maddila Shankar
maddila Shankar - avatar
0
continue--> loop continues statement dont execute for that loop only break--> loop breaks totally
20th Aug 2017, 3:35 PM
sayan chandra
sayan chandra - avatar
0
thank you Jeremy..😁
20th Aug 2017, 3:35 PM
maddila Shankar
maddila Shankar - avatar