title: Adding Arrays to an ArrayList
body: <p>What I am trying to do is add an array to an arraylist.  I've looked at other examples that tell me to do what I am doing, but I get nonsense output when I run the program.  I would also like to access certain elements of an array within the arraylist, and I have no idea how to do that.</p>
  
  <pre><code>static int elements = 10;  //Or whatever number you'd like
  
  public static void main(String[] args)
      {
          int[] person = new int[4];
          ArrayList personID = new ArrayList();
  
          experiment(personID, person);
      }
  
  private static void experiment(ArrayList personID, int[] person)
      {
          for(int i = 0; i &lt; elements; i++)
              {
                  person[0] = i;
                  person[1] = i;
                  person[2] = i;
                  person[3] = i;
  
                  personID.add(person);
              }
          System.out.print(personID);
      }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>[[I@e1cba87, [I@e1cba87, [I@e1cba87, [I@e1cba87, [I@e1cba87, [I@e1cba87, [I@e1cba87, [I@e1cba87, [I@e1cba87, [I@e1cba87]
  </code></pre>
  
  <p>Not that much of an explanation is needed, but I declare the array and arraylist, pass them to a function which keeps giving the array's elements different values and then, supposedly, adding the array itself to the arraylist for each iteration.</p>
  
  <p>The output, though, it nothing like what I am looking for.  I could do another loop to print each array element for each spot along the array list, but I don't know how to do that.  I figured</p>
  
  <pre><code>System.out.print(personID.get(i[0]);
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>System.out.print(personID.get(i)[0];
  </code></pre>
  
  <p>But it doesn't work and I'm lost...</p>
  
  <p>Thank you for dealing with me!</p>