Demo for loop : Array « JSP « Java






Demo for loop

<%--
  Copyright (c) 2002 by Phil Hanna
  All rights reserved.
  
  You may study, use, modify, and distribute this
  software for any purpose provided that this
  copyright notice appears in all copies.
  
  This software is provided without warranty
  either expressed or implied.
--%>
<%!
   static final String[] COLORS = {
      "#CA9A26",
      "#3BF428",
      "#F7E339",
      "#FF40FF",
   };
%>
<%
   for (int i = 0; i < COLORS.length; i++) {
      String color = COLORS[i];
%>
<div style="background-color: <%= color%>;
            font-size: 12pt;
            font-weight: bold;">
   This is color <%= color %>
</div>
<% } %>


           
       








Related examples in the same category

1.Creating an Array
2.Using Multidimensional Arrays
3.Int array
4.Passing Arrays to Methods