title: How to pass empty list with type parameter?
body: <pre><code>class User{
      private int id;
      private String name;
  
      public User(int id, String name) {
          this.id = id;
          this.name = name;
      }
  }
  
  class Service&lt;T&gt; {
      private List&lt;T&gt; data;
      public void setData(List&lt;T&gt; data) {
          this.data = data;
      }
  }
  
  public class ServiceTest {
      public static void main(String[] args) {
          Service&lt;User&gt; result=new Service&lt;User&gt;();
          result.setData(Collections.emptyList()); // problem is here
      }
  }
  </code></pre>
  
  <p>How to pass empty list with type parameter?</p>
  
  <p>compiler giving me error message: </p>
  
  <blockquote>
    <p>The method setData(List&lt; User > ) in the type Service is not
    applicable for the arguments (List&lt; Object > )</p>
  </blockquote>
  
  <p>and if I try to cast with List then the error: </p>
  
  <blockquote>
    <p>Cannot cast from List&lt; Object > to List&lt; User ></p>
  </blockquote>
  
  <p><code>result.setData(new ArrayList&lt;User&gt;());</code> is working fine but I don't want to pass it.</p>