title: java generics - convert List<object> to List<T>
body: <p>I have a class <code>MySpecialClass &lt;T extends Comparable&lt;T&gt;&gt;</code></p>
  
  <p>I am trying to to do the following:</p>
  
  <p><code>toItemList()</code> -> should take <code>List&lt;Dog&gt;</code> and convert it to <code>List&lt;T&gt;</code> so the <code>MySpecialClass</code> can operate on it.</p>
  
  <p><code>fromItemList()</code> -> should take in memory <code>List&lt;T&gt;</code> and convert it to List of objects. So if I have List it should convert it to <code>List&lt;Dog&gt;</code>, so I can get a back conversion after all operations are done.</p>
  
  <p>How do I construct something like that in Java? My <code>MySpecialClass</code> works with <code>List&lt;T&gt;</code> which is why I need that.</p>
  
  <pre><code>public List&lt;T&gt; toItemList(List&lt;dogs&gt; list or List&lt;cats&gt; list){
  // how to convert?      
  
      }
  
  
  
  public List&lt;dog&gt; or List&lt;cat&gt;  fromItemList(){
        //local _inMemoryList (which is List&lt;T&gt;) convert to List&lt;dog&gt; or List&lt;cat&gt; depending on what MySpecialClass T is   
   // how to convert?     
  
          }
  </code></pre>
  
  <p>PS I am very new to java, always worked with .net so don't judge :)</p>