Explain break and Continue.
In : BSc IT Subject : Structure Programming Methodology - JavaThe break statement is used to immediately exit a loop (like for, while, or do-while) or a switch statement. As soon as break is encountered, the program stops the loop and continues with the next part of the code.
Example:
for (int i = 1; i <= 5; i++) {
if (i == 3) {
break; // Stop the loop when i is 3
}
System.out.println(i);
The continue statement is used to skip the current iteration of a loop and move to the next one. It doesn't stop the whole loop — just the current round.
Example:
for (int i = 1; i <= 5; i++) {
if (i == 3) {
continue; // Skip when i is 3
}
System.out.print