How do I declare a list with the class name in a string. For eg: I have a className variable with the name of a class. I need to create List with the type in the className variable.
String className ="com.foo.Foo";
Is it possible to have a list that is having the same result of
List<Foo> fooList = new ArrayList<Foo>();
without knowing the type at the time of declaration.
List fooList = new ArrayList();and cast the results when accessing the list (it is now just a list of (unchecked) Objects)List<Object>(which in most cases is, what the compiler make out ofList<Something>anyway thanks to Type Erasure)?