difference between break and continue

break and continue keywords are used mainly in loops.
break and continue are java keywords.
Below is purpose of break:
When a break; statement is encountered, the loop under execution is exited, and the control does to immediate statement after the loop.
break statement is also used with switch case statement.
break is also used with labels. how to use labels in Java
Below is purpose of continue:
When continue statement is encountered, current iteration of the loop is ignored, control goes back to beginning of loop, and execution continues with next iteration.

Generally break and continue statements are within a conditional statement, otherwise they tend to get executed, for every iteration.

You may also like to read:
How many Java keywords are there
How to check if number is composite or prime

Leave a Reply