title: Java Generics : Unchecked cast from List<capture#10-of ?> to List<Object>
body: <p>I have a warning :
      <code>Type safety: Unchecked cast from List &lt; capture#10-of ?&gt; to List &lt; Object&gt;</code></p>
  
  <p>There is the call, <code>stock.getListDVD().getListDVD()</code> is an <code>ArrayList&lt;DVD&gt;</code></p>
  
  <pre><code>jTablePanier=new JTableUt(stock.getListDVD().getListDVD(), DVD.class);
  </code></pre>
  
  <p>So i know the class it's a DVD.class</p>
  
  <pre><code>private ModelJTableUt model;    
  public JTableUt(List&lt;?&gt; list, Class&lt;?&gt; classGen)
  {               
      model=new ModelJTableUt((List&lt;Object&gt;) list, classGen); // &lt;-- This line cause the warning, i convert List&lt;?&gt; to List&lt;Object&gt;
  }
  
  public ModelJTableUt(List&lt;Object&gt; list, Class&lt;?&gt; classGen) {
  </code></pre>
  
  <p>How can i resolve this warning without using </p>
  
  <pre><code>@SuppressWarning("unchecked")
  </code></pre>
  
  <hr>
  
  <p>Thanks a lot for your help. It save me many hours.
  The solution is </p>
  
  <pre><code> public JTableUt(List&lt;? extends Object&gt; list, Class&lt;?&gt; classGen){
      model=new ModelJTableUt(list, classGen);
   }
  
   List&lt;Object&gt; list;
   public ModelJTableUt(List&lt;? extends Object&gt; list2, Class&lt;?&gt; classGen) 
   {
       list = new ArrayList&lt;Object&gt;();
   //I construct a new List of Object.    
       for (Object elem: list2)
       {
           list.add(elem);
       }
   }
  </code></pre>