title: How to use the get(int index) method of arraylist having nodes as records with data fields
body: <p>I need to be clarified on the use of get(int index) method to check on the record data fields of nodes in an arraylist.. </p>
  
  <pre><code>    import java.util.ArrayList;
  
      public class ArrayNodeDemo {
      public static void main(String args[]) {
  
      ArrayList&lt;Object&gt; lstObject = new ArrayList&lt;Object&gt;();
  
      Person p1 = new Person();
      p1.setPersonId(1);
      p1.setPersonName("Tom");
      lstObject.add(p1);
  
      Person p2 = new Person();
      p2.setPersonId(2);
      p2.setPersonName("Jerry");
      lstObject.add(p2);
  </code></pre>
  
  <p>The following code gives the node locations:</p>
  
  <pre><code>    System.out.println("1st record : " + lstObject.get(0));          
      System.out.println("2nd record : " + lstObject.get(1));
  
        }
       }
  </code></pre>
  
  <p>While, the following gets an error:</p>
  
  <pre><code>    System.out.println("1st record : " + lstObject.get(0).getPersonId());          
      System.out.println("2nd record : " + lstObject.get(1).getPersonId());
  
        }
       }
  </code></pre>