The break and continue Statement
Using break statement : When a break statement is encountered inside a loop, the loop is terminated and program control resumes at the next statement following the loop. Here is a simple example: /** * This program demonstrates * break to exit a loop. */ public class BreakDemo { public static void main(String[] args) { for…