Break Statement in JSP
The use of break statement is to escape early from the loop. It allows the program to escape from the for, while, switch and do while loops. A break may only appear on one of these statements. It is mainly used to escape early from the loop.
In this program we are using the switch statement under which we will use break statement. The for loop will run from 0 to 5.
The code of the program is given below:
<html> <head> <TITLE> break Statement in jsp</TITLE> </HEAD> <BODY> <table> <H1>break Statement in jsp</H1> <% for(int i =0; i <= 5; i++) { switch(i){ case 0: out.println(i+ "is zero."+"<br>"); break; case 1: out.println(i+ "is one."+"<br>"); break; case 2: out.println(i +"is two."+"<br>"); break; case 3: out.println(i+" is three."+"<br>"); break; case 4: out.println(i+"is four."+"<br>"); break; case 5: out.println(i+"is five."+"<br>"); break; default: out.println(i+" is greater than 6"); } } %> </table> </BODY> </HTML> |
Output of the Program: