import static java.lang.System.err;
import java.lang.reflect.Method;
public class FindPublicMethodsInAClass
{
public static void main(String ...vars) {
if (vars.length <= 0) {
err.format("Enter Class name") ;
return ;
}
try{
Class<?> inputclass = Class.forName(vars[0]) ;
Object obj = inputclass.newInstance() ;
Method[] methods = ((Class<?>) obj).getDeclaredMethods() ;
for ( Method method : methods) {
System.out.println("Method Name: " + method.getName());
}
}catch(ClassNotFoundException | InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment