title: How to define a generic List of types in java?
body: <p>I have implemented a java method with the following signature:</p>
  
  <pre><code>public &lt;T&gt; T getItemValue(String itemName, Class&lt;T&gt; itemType)  {
  ...
  }
  </code></pre>
  
  <p>This allows a client to call the method in the following way to get for example a value of the type String or Integer:</p>
  
  <pre><code>String s = itemCol.getItemValue("_name", String.class);
  int i = itemCol.getItemValue("_count", Integer.class);
  </code></pre>
  
  <p>This kind of method signature is also used by the <a href="https://github.com/eclipse/microprofile-config/blob/master/api/src/main/java/org/eclipse/microprofile/config/Config.java#L90" rel="nofollow noreferrer">Config interface</a> of the new microprofile Config 1.3 API.</p>
  
  <p>My question is how - or if - I can call the method with a Type of List of Types like <code>List&lt;String&gt;</code> to get for example a List of String objects. 
  I was not able to formulate the client call. I tried something like this:</p>
  
  <pre><code>List&lt;String&gt; list = itemCol.getItemValue("_count", List&lt;String.class&gt;);
  </code></pre>
  
  <p>but this seems not to be the correct syntax.</p>
  
  <p><strong>EDITED:</strong></p>
  
  <p>As a result of the responses below I decided to add a separate method to get a List of a specific type.</p>
  
  <pre><code>public &lt;T&gt; List&lt;T&gt; getItemValueList(String itemName, Class&lt;T&gt; itemType) {
          ...
  }
  </code></pre>
  
  <p>With this additional method signature a client can decide weather to get a single value or a list of a specific type. </p>