标签:
以下这个URL讲得不错,可以把概念和用途结合起来,
练练手:
http://blog.csdn.net/xiaohai798/article/details/11640427
import java.lang.reflect.Field; import java.lang.reflect.Method; import javax.swing.JOptionPane; /** java reflect */ public class MyTest { public MyTest() { String classInfo = JOptionPane.showInputDialog(null, "Input class full path: "); try { Class cla = Class.forName(classInfo); Method[] method = cla.getDeclaredMethods(); for(Method me:method){ System.out.println(me.toString()); } System.out.println("*************"); Field[] field = cla.getDeclaredFields(); for(Field me:field) { System.out.println(me.toString()); } } catch (ClassNotFoundException e) { e.printStackTrace(); } } public static void main(String[] args) { new MyTest(); } }
标签:
原文地址:http://www.cnblogs.com/aguncn/p/5457321.html