Java Tutorial/JSP/Array

Материал из Java эксперт
Перейти к: навигация, поиск

Creating an Array

<HTML>
  <HEAD>
    <TITLE>Creating an Array</TITLE>
  </HEAD>
  <BODY>
    <H1>Creating an Array</H1>
    <%
        double accounts[];
        accounts = new double[100];
        accounts[3] = 119.63;
        out.println("Account 3 holds $" + accounts[3]);
     %>
  </BODY>
</HTML>





Using Multidimensional Arrays

<HTML>
  <HEAD>
    <TITLE>Using Multidimensional Arrays</TITLE>
  </HEAD>
  <BODY>
    <H1>Using Multidimensional Arrays</H1>
    <%
        double accounts[][] = new double[2][100];
        accounts[0][3] = 119.63;
        accounts[1][3] = 194.07;
        out.println("Savings Account 3 holds $" + accounts[0][3] + "<BR>");
        out.println("Checking Account 3 holds $" + accounts[1][3]);
     %>
  </BODY>
</HTML>