I have List<Zones> and List<Locations> and i am passing it to a generic function…
public String checkListType(List<?> checkList){
// Now here I want to check if list is of type locations than
return "locations"
else {
return "Zones";
}
}
This looks like an XY problem. I’ll answer it as asked, but if you provide more information about what you’re trying to do, I may have a better answer for you.
Generics in Java are not available at runtime; http://docs.oracle.com/javase/tutorial/java/generics/erasure.html
You have a few options. You could pass the class into the method.
You could also use reflection to identify the type of the first element.