title: foreach not applicable to java.lang.object and compilation error when trying to iterate through array list of array lists in java
body: <p>I have an array list of array lists. And I am trying to iterate through them. However I keep getting compilation error. Where am I going wrong. Is there a better way to iterate.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>import java.util.ArrayList;
  
  public class ListofLists {
      public static ArrayList family() {
          // ArrayList of ArrayLists
          ArrayList&lt;ArrayList&lt;String&gt;&gt; couples = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
          ArrayList&lt;String&gt; husbands = new ArrayList&lt;String&gt;();
          husbands.add("brad");
          husbands.add("jessie");
          couples.add(husbands);
          ArrayList&lt;String&gt; wives = new ArrayList&lt;String&gt;();
          wives.add("jolie");
          wives.add("jena");
          couples.add(wives);
          return couples;
      }
  
  
      public static void main(String[] args) {
          ArrayList couples = family();
  
          for (Object couple : couples) {
              for (String person: couple) {
                  System.out.println(person);
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>Compilation Error:</strong></p>
  
  <pre><code>required: array or java.lang.Iterable
    found:    Object
  </code></pre>
  
  <p><strong>Expected Output:</strong></p>
  
  <pre><code>brad
  jessie
  jolie
  jena
  </code></pre>