+ 3

What is the difference between break and continue?

in java

1st Mar 2017, 6:31 PM
Pratham
Pratham - avatar
2 Respuestas
+ 2
break , helps to come out of loop , if certain condition holds good. continue , continues the loop. Example for(int i=0;i<=10;i=i+2){ System.out.println(i); if(i==6) break; } Here when i reaches 6 , the loop will break/end.Hence max value of i is 6 not 10.
1st Mar 2017, 6:44 PM
Meharban Singh
Meharban Singh - avatar
+ 1
break is used end the loop and continue is used to decrease 1 loop
2nd Mar 2017, 7:46 PM
Wazed Ali Gazi
Wazed Ali Gazi - avatar