title: Returning an ArrayList of any type
body: <p>I have some <code>ArrayList</code>s declared. Some of them are <code>ArrayList&lt;Integer&gt;</code> and other are <code>ArrayList&lt;Double&gt;</code>.</p>
  
  <p>I want to get them from another class, so I wrote a method:</p>
  
  <pre><code>private ArrayList&lt;Double&gt; list1, list2;
  private ArrayList&lt;Integer&gt; list3;
  
      public ArrayList getList(String nameOfList){
          ArrayList myList = new ArrayList();
          if(nameOfList.equals("list1")) myList = list1;
          else if(nameOfList.equals("list2")) myList = list2;
          else if(nameOfList.equals("list3")) myList = list3;
          return myList;
      }
  </code></pre>
  
  <p>This compiles, but throws me some warnings:</p>
  
  <pre><code>*ArrayList is a raw type. References to generic type ArrayList&lt;E&gt; should be parameterized* in the method above, and *Type safety: The expression of type ArrayList needs unchecked conversion to conform to List&lt;? extends Number&gt;* when calling the method from here:
  
      XYSeries series = new SimpleXYSeries(data.getList("list1"), data.getList("list2"), "My chart");
  
  where SimpleXYSeries is a chart whose constructor expects to be getting **(List&lt;? extends Number&gt;, List&lt;? extends Number&gt;, String)**.
  </code></pre>
  
  <p>Which is the right way to do what I'm intending to do?</p>