I have this code below (which is deserializing a class):
....
Type type = field.getGenericType();
if (type instanceof ParameterizedType) {
ParameterizedType ptype = (ParameterizedType) type;
if(c.getSimpleName().equals("Vector")){
Class pta = (Class) ptype.getActualTypeArguments()[0];
Vector<what to put here> v = (Vector)field.get(obj);
if(v == null){
v = new Vector<what to put here>();
field.set(obj, v);
}
....
My question is how do I change the Vector to take a certain type of data just from knowing the class name of what it took before (which would be the pta var)?
Generics are resolved at compile time, so there is no way to do this as you have listed. Just use a
Vector<Object>orVector