rgumentos de tipo genérico Java [duplicado]
Esta pergunta já tem uma resposta aqui:
Get type genérico de java.util.List 14 respostasTenho um método que usa umList<?>
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);
Emmethod
, como sei searg
é umList
doClassA
ouList
doClassB
?