Using the break Statement : Statements « JSP « Java






Using the break Statement

<HTML>
  <HEAD>
    <TITLE>Using the break Statement</TITLE>
  </HEAD>

  <BODY>
    <H1>Using the break Statement</H1>
    <%
        double array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int sum = 0;

        for(int i = 0; i <
            array.length; i++) {

            sum += array[i];
            if (sum > 12) break;
            out.println("Looping...<BR>");
        }
        out.println("The sum exceeded the maximum allowed value.");
    %>
  </BODY>
</HTML>

           
       








Related examples in the same category

1.Using the continue Statement
2.While statement
3.While: Finding a Factorial
4.Using the while Loop
5.For loop: Using Two Loop Indexes
6.Using the if Statement
7.Testing for Multiple Conditions
8.Using the switch Statement
9.Using an if-else Ladder
10.Nested if Statements
11.Using Compound Statements