Using an if-else Ladder : If « JSP « Java Tutorial






<HTML>
  <HEAD>
    <TITLE>Using an if-else Ladder</TITLE>
  </HEAD>

  <BODY>
    <H1>Using an if-else Ladder</H1>
    <%
        String day = "Friday";

        if(day == "Monday")
            out.println("It\'s Monday.");
        else if (day == "Tuesday")
            out.println("It\'s Tuesday.");
        else if (day == "Wednesday")
            out.println("It\'s Wednesday.");
        else if (day == "Thurssday")
            out.println("It\'s Thursday.");
        else if (day == "Friday")
            out.println("It\'s Friday.");
        else if (day == "Saturday")
            out.println("It\'s Saturday.");
        else if (day == "Sunday")
            out.println("It\'s Sunday.");
    %>
  </BODY>
</HTML>








23.6.If
23.6.1.Using the if Statement
23.6.2.Using Compound Statements
23.6.3.Nested if Statements
23.6.4.Using an if-else Ladder