Wednesday, April 18, 2007

When do you use 'continue' and 'break' statements?

When one wants to complete the iteration of a loop prematurely then 'continue' statement is used.
While the 'break' statement is used to exit the entire loop whenever encountered.

1 comments :

Anonymous said...

If you have nested loops/if statements, how far out will 'continue' and 'break' operate? For example:

while(condition1){

while(condition2){

if(condition3){
continue;
}
else{
break;
}

}

}

 

Disclaimer
Interview Questions On Java,Java EE Copyright © 2017. Reads: best tracker