class MethodFinder {
public static String findMethod(String methodName, String[] classNames) {
for(String cn: classNames){
if(cn.getMethods() == methodName){
return methodName.getName();
}
}
}
}
The method should return fully qualified name of a class.How to fix it? For example, the method name is abs and possible classes are String
, StringBuffer
and Math.
String
and StringBuffer
have no method with the name abs. So they are not the class we are looking for. Math
class has a method with the name abs
. The method should return the fully-qualified name of Math
class, java.lang.Math
in this case.
Aucun commentaire:
Enregistrer un commentaire