title: loop arraylist of array in java
body: <ul>
  <li><p>I want to loop trough an arraylist of String arrays.</p></li>
  <li><p>These string arrays have only two elements. inside the loop i would like to compare these two elements of each array.</p></li>
  <li><p>i would like to do this in a clean and simple way (avoiding classic for, iterator class, etc., if possible -i know how to do this those ways, but I'm looking for a cleaner way-.</p></li>
  <li><p>i would prefer a for-each loop (or for + ":")</p></li>
  <li><p>I'm attaching a sample code to show you what i want to do.</p></li>
  </ul>
  
  <p>what is the best way for doing this? </p>
  
  <pre><code>ArrayList&lt;String[]&gt; myLst = new ArrayList&lt;String[]&gt;();
  
  // the array of strings has two elements
  
  public String getSecondField(String query)
  {
      for (String[] binArray : myLst)
      {
          if (binArray[0].equals(query))
          {
              return binArray[1];
          }
      }
      return "";
  }
  </code></pre>