title: Java - How to iterate through an ArrayList for adding elements?
body: <p>I'm new to java and I want to get all data from a class.</p>
  
  <p>This is how I add data to the class:</p>
  
  <pre><code>String[] arrNames = { "Andrew", "James" ... };
  ...
  
  for(int i = 0; i &lt; arrNames.length; i++){
     Person person = new Person();
     person.setId(i + 1);
     person.setName(arrNames[i]);
     person.setLastname(arrLastnames[i]);
     person.setIdentifier(arrIds[i]);
     person.setAddress(arrAddreses[i]);
  }
  </code></pre>
  
  <p>How can I get all those data that I have added to the class?</p>
  
  <pre><code>for(Person p : ???){
     System.out.println(p.getName());
  }
  </code></pre>