title: Get ArrayList from Object
body: <p>I have one method that returns an object with two arraylists:</p>
  
  <pre><code>return new Object[] {work, play};
  </code></pre>
  
  <p>I am trying to get them back out in another method. I have tried casting to ArrayList but I get the error 'array required, but java.lang.Object found'.</p>
  
  <pre><code>ArrayList setWork = (ArrayList)obj[0];
  ArrayList setPlay = (ArrayList)obj[1];
  </code></pre>
  
  <p>Full code for ArrayList creation:</p>
  
  <pre><code>public static Object[] getWorkandPlay(ArrayList al) {
  
      ArrayList work = new ArrayList();
      ArrayList play = new ArrayList();
  
      for (int i=0; i&lt;al.size(); i++){
          String item = (String) al.get(i);
  
          if (item.startsWith("w.")) {
              System.out.println("w " + item);
              work.add(item);
          } else if (item.startsWith("p.")) {
              System.out.println("p " + item);
              play.add(item);
          } else {
              System.out.println("Entries must start with either w. or p.\n");
          }
      }
      return new Object[] {work, play};
  }
  </code></pre>