Java argumentos de tipo genérico [duplicado]
Esta pregunta ya tiene una respuesta aquí:
Obtenga el tipo genérico de java.util.List 14 respuestas Tengo un método que toma unList<?>
como argumento.
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);
Inmethod
, ¿cómo sé siarg
es unList
deClassA
o unList
deClassB
?