How to create class of T?
I need to bind from some Windows Communication Foundation (WCF) XML of the object T.
I can do this without errors:
ArrayList<T> list = new ArrayList<T>();
This is my function:
public static <T> ArrayList<T> GetListFromXml(String url,String element)
How to get: T obj = ?
That is not possible due to the type erasure of the compiler. If you have a concrete type with a default constructor on caller side, the following may work:
If you need to pass parameters to the constructor, you have to get it from the class by
getConstructor(parameter type 1, ...)(you need to handle the Exceptions not shown here):