我有一个方法,它接收一个
在
List<?>
作为参数。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);
在
method
中,我如何知道arg
是ClassA
的List
还是ClassB
的List
?
<?>
意味着您对实际类型不感兴趣。 - biziclop