How To Instantiate a java.util.ArrayList with Generic Class Using Reflection
<p>How To Instantiate a java.util.ArrayList with Generic Class Using Reflection? I am writing a method that sets java.util.List on target object. A target object and a generic type of list is knowing in runtime:</p>

<pre><code>public static void initializeList(Object targetObject, PropertyDescriptor prop, String gtype) {
    try {
        Class clazz = Class.forName("java.util.ArrayList&lt;"+gtype+"&gt;");
        Object newInstance = clazz.newInstance();
        prop.getWriteMethod().invoke(targetObject, newInstance);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
</code></pre>
