+ 3
What is the difference between break and continue?
in java
2 Antworten
+ 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.
+ 1
break is used end the loop and continue is used to decrease 1 loop