title: Java: How can I get generic type in runtime?
body: <pre><code>Class clazz = parameter.getParameterType();
  </code></pre>
  
  <p>Here I have <code>clazz</code>, which i'm certain that this is <code>Optional&lt;T&gt;</code> type class. The problem is how can I get this <code>T</code>? I want to know if this is <code>String</code> or <code>Long</code> or <code>Integer</code> or something in the runtime.</p>
  
  <p>ok, I think I didn't put it clearly. I got a method parameters by reflection,</p>
  
  <pre><code>public String abc(Optional&lt;String&gt; ttt, Optional&lt;Integer&gt; bbb) {
      return;
  }
  </code></pre>
  
  <p>So now I have the class of ttt, and bbb, and i'm sure that this is <code>Optional&lt;T&gt;.class</code>, but can I get which <code>T</code> elasctly that is.</p>