public class A {
public void b(){}
public void c(){}
public void d(){}
public void e(){}
}
import java.lang.reflect.Method;
public class StaticTest {
public static void test(Object obj)
{
Class myclass = obj.getClass();
//System.out.println(myclass.getName());
Method[] mymethods = myclass.getDeclaredMethods();
int n = mymethods.length;
for(int i=0; i<n; i++)
{
System.out.println("类名:"+myclass.getName()+"; 方法名:"+mymethods[i].getName());
}
}
public static void main(String args[]){
A a = new A();
test(a);
}
}
|