title: How to create objects inside a loop on 2d array in Java
body: <p>I have a class</p>
  
  <pre><code>public class SimpleData() {
      String continent;
      String country;
      String city;
  
      public SimpleData(String continent, String country, String city) {
          this.continent = continent;
          this.country = country;
          this.city = city;
      }
  
  }
  </code></pre>
  
  <p>And another class that gets data from a file and returns a 2d Object array</p>
  
  <pre><code>private Object[][] getDataFromFile(String fileName) {
      return dataLoader.getTableArray(fileLocation, dataSheetName);
  }
  
  //will return something like
  europe, uk, london
  europe, france, paris
  </code></pre>
  
  <p>How can I create objects of SimpleData when looping through the 2d array and adding the objects to a list so that each object of SimpleData represents a row of data?</p>
  
  <pre><code>private List&lt;SimpleData&gt; getDataList() {
      Object[][] array = readDataFromFile("myfile");
      List&lt;SimpleData&gt; dataList = new ArrayList&lt;SimpleData&gt;();
  
      for (int i = 0; i &lt; arr.length; i++) {
          for (int j = 0; j &lt; arr[i].length; j++) {
              //what's the code to generate object with the correct row of data?
          }
      }
      return dataList;
  }
  </code></pre>