反射的第一个案例 helloword
package bean;
import java.lang.reect.Method;
public class test {
private void show(){}
public void showe(){}
public static void main(String[] args) {
try {
Class c=Class.forName("bean.test");
Method ms[]=c.getDeclaredMethods();
for(Method m:ms){
System.out.println(m.getModi&ers()+"\t"+m.getName());
}
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
第 1 页 / 共 22 页