Testing for Multiple Conditions : Switch « JSP « Java Tutorial






<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>








23.7.Switch
23.7.1.Using the switch Statement
23.7.2.Testing for Multiple Conditions