Your for statement to loop through an array : for « JSP « Java Tutorial






<HTML>
  <HEAD>
    <TITLE>My First JSP</TITLE>
  </HEAD>

  <BODY>
    <H1>Using the if Statement</H1>
    <%
        int array[] = {1, 2, 3, 4, 5}, sum = 0;

        for (int i = 0; i < array.length; sum += array[i++]);

        out.println("The average = " + sum / array.length);
    %>
  </BODY>
</HTML>








23.8.for
23.8.1.Using the for Statement
23.8.2.Finding Average Grades
23.8.3.Using Two Loop Indexes
23.8.4.Your for statement to loop through an array