title: How to create Instance by java.lang.reflect.Type
body: <p>I want to set property of class by using reflect, and my class has a <code>List&lt;Article&gt;</code> property.</p>
  
  <p>I just get the generics type of the <code>List&lt;Article&gt;</code> by below code</p>
  
  <pre><code>Method[] methods = target.getClass().getMethods();
  String key = k.toString(), methodName = "set" + key;
  Method method = getMethod(methods, methodName);
  if (Iterable.class.isAssignableFrom(method.getParameterTypes()[0])) {
      // at there, i get the generics type of list
      // how can i create a instance of this type?
      Type type = getGenericsType(method);
  }
  
  
  public static Method getMethod(Method[] methods, String methodName) {
      for (Method method : methods) {
          if (method.getName().equalsIgnoreCase(methodName))
              return method;
      }
      return null;
  }
  
  private static Type getGenericsType(Method method) {
      Type[] types = method.getGenericParameterTypes();
      for (int i = 0; i &lt; types.length; i++) {
          ParameterizedType pt = (ParameterizedType) types[i];
          if (pt.getActualTypeArguments().length &gt; 0)
              return pt.getActualTypeArguments()[0];
      }
      return null;
  }
  </code></pre>
  
  <p><br /></p>