Java generische Typ Argumente [duplizieren]
Diese Frage hat hier bereits eine Antwort:
Holen Sie sich den generischen Typ von java.util.List 14 answersIch habe eine Methode, die ein @ nimList<?>
als Argument.
public static String method(List<?> arg){
// Do something based on type of the list
}
//I call the method as below
List<ClassA> listA = new ArrayList<ClassA>();
List<ClassB> listB = new ArrayList<ClassB>();
method(listA);
method(listB);
Immethod
, woher weiß ich, obarg
ist einList
vonClassA
oder einList
vonClassB
?