title: Java: How to have list type take variable arguments
body: <p>I have a class like this</p>
  
  <pre><code>class Dummy{
      public getData(Info info){
          List&lt;SomeType&gt; list = info.getDataAsPerInfo();
  
          List&lt;SomeType&gt; result=new List&lt;&gt;();  
  
          for(SomeType someType: list){
              // extracting data from someType, lets say this data is 
              // resType (it also of SomeType)
              result.add(resType);  
          }
      }
  
      public static void main(String args[]){
          Info1 info = new Info1();   // Info1 extends Info
          // adding paramters to info
          new Dummy().getData(info);
      }
  }
  </code></pre>
  
  <p>Now the problem is that I have several Info classes like <code>Info1, Info2 ...</code>
  and there getData method might return different types of list. I can't figure how to achieve this without rewriting the code for each and every Info class( this would involve replacing <code>SomeType</code> with the return type of that class' getdataAsPerInfo function).
  Is there a way such that I can somehow use <code>SomeType</code> according to the Info type that is passed to the getData function? What would be the best approach in this case? Thanks !! </p>