So, I've tried to get object type of a given class to parse into ArrayList Example:
public class Util{
public static void makeArray(String tag, Class<?> forClass) {
ArrayList<?> list = new ArrayList();
}
}
How can I replace <?>
with forClass
object type? So back in main method when I call
Util.makeArray("names", String.class);
It would create ArrayList<String>
and if I say
Util.makeArray("ages", int.class);
It would resolve it to ArrayList<Integer>
And if it is not even done this way, show how.
Aucun commentaire:
Enregistrer un commentaire