Java Tutorial/JSP/Switch — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 05:07, 1 июня 2010
Testing for Multiple Conditions
<HTML>
<HEAD>
<TITLE>Testing for Multiple Conditions</TITLE>
</HEAD>
<BODY>
<H1>Testing for Multiple Conditions</H1>
<%
int temperature = 64;
switch(temperature) {
case 60:
case 61:
case 62:
out.println("Sorry, too cold!");
break;
case 63:
case 64:
case 65:
out.println("Pretty cool.");
break;
case 66:
case 67:
case 68:
case 69:
out.println("Nice!");
break;
case 70:
case 71:
case 72:
case 73:
case 74:
case 75:
out.println("Fairly warm.");
break;
default:
out.println("Too hot!");
}
%>
</BODY>
</HTML>
Using the switch Statement
<HTML>
<HEAD>
<TITLE>Using the switch Statement</TITLE>
</HEAD>
<BODY>
<H1>Using the switch Statement</H1>
<%
int day = 3;
switch(day) {
case 0:
out.println("It\"s Sunday.");
break;
case 1:
out.println("It\"s Monday.");
break;
case 2:
out.println("It\"s Tuesday.");
break;
case 3:
out.println("It\"s Wednesday.");
break;
case 4:
out.println("It\"s Thursday.");
break;
case 5:
out.println("It\"s Friday.");
break;
default:
out.println("It must be Saturday.");
}
%>
</BODY>
</HTML>