I need to write a function to return true if the incoming java Class is an implementation of the interface List. Does anybody know how to do this in java?
something like:
public boolean canConvert(Class c) {
//return true is c is an implementation of the interface List
}
Thanks
There are two distinct scenarios:
you want to check if a given class is a subclass/implementor of
List. Judging from your method signature (Class c), this is what you want. In that case useyou want to see if a given object is an instance of a class that us a subclass/implementor of
List. In that case useobj instanceof List, as Bala R suggested.