Here is an example program. Right by the comment will fail, I want to know if I can create a method that achieves this functionality of creating a list at runtime.
import java.util.ArrayList;
import java.util.List;
public class ListMaker
{
public static List<?> makeList(Class clazz)
{
// I want to do something like this
return new ArrayList<clazz>();
}
public static void main(String[] args)
{
Vo object = new Vo(100);
ArrayList<Vo> list = makeList(Vo.class);
list.add(object);
}
}
class Vo
{
int i;
public Vo(int i){this.i = i;}
}