`
cax_2014
  • 浏览: 9613 次
社区版块
存档分类
最新评论

java反射技术随笔

 
阅读更多

本文参考:http://www.cnblogs.com/jqyp/archive/2012/03/29/2423112.html

简单的来说,反射机制指的是程序在运行时能够获取自身的信息。在java中,只要给定类的名字, 那么就可以通过反射机制来获得类的所有信息,类中有什么信息,它就可以通过className获得什么信息

备注:

Method getDeclaredMethod(String name, Class[] params)//根据方法名和参数类型,获得public和非public的方法,只列出用户自己定义的方法

Method[] getMethods()//获得所有的public方法,同时包括从父类继承过来的方法

Field field = CommonDictionary.class.getDeclaredField(orderFiled);
String type = field.getType().getSimpleName();
Method method = CommonDictionary.class.getDeclaredMethod(generateMethodName(), new Class[] {});

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics