Class c = v.getClass(); try { Method m = c.getMethod("something"); if(!m.getReturnType().equals(Boolean.TYPE)) {return false;} } catch(NoSuchMethodException e) {return false;}
... where v is an object of a particular class.
When I try to compile this, I get:
error: cannot find character
Method m = c.getMethod ("something");
^
Method is a type that is located in java.lang.reflect.Method . According to my knowledge, java.lang and all subsequent ones are imported by default, but I even did this explicitly:
import java.lang.*;
So my question is: how can I get my compiler to recognize the Method class, or how can I save the return value of getMethod otherwise?
PS: Please ignore the unverified call to the getMethod method, this will be a problem at another time (maybe another question).
source share