title: How do I access a specific element from a nested ArrayList
body: <p>I have two ArrayLists</p>
  
  <pre><code>private ArrayList&lt;ArrayList&lt;String&gt; dataList = new ArrayList&lt;&gt;();
  //This is a class variable
  
  ArrayList&lt;String&gt; dataRow = new ArrayList&lt;&gt;();
  //This is a method variable
  </code></pre>
  
  <p>I add items to dataRow</p>
  
  <pre><code>dataRow.add("number");
  dataRow.add("firstName");
  dataRow.add("surname");
  dataRow.add("dateStart");
  dataRow.add("dateEnd");
  </code></pre>
  
  <p>and then I add each dataRow to dataList resulting in an ArrayList of ArrayLists</p>
  
  <pre><code>dataList.add(dataRow);
  </code></pre>
  
  <p>My Question is:</p>
  
  <p>I need to select just elements 3 and 4 from each dataRow and I can't find any code that works.</p>
  
  <p>I have tried</p>
  
  <pre><code>for (ArrayList&lt;String&gt; eachRow : dataList)
  {
      For (String eachElement : eachRow)
      (
          System.out.println(eachElement)
      }
  }
  </code></pre>
  
  <p>All this does is print out all the elements</p>
  
  <p>I have also tried other code such as </p>
  
  <pre><code>dataList.get(eachElement)
  </code></pre>
  
  <p>this throws a no suitable method error in netbeans</p>