A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

[技术笔记] Class对象功能

© 起个名字真难QAQ 初级黑马   /  2018-11-29 14:08  /  508 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

* Class对象功能:
        * 获取功能:
                1. 获取成员变量们
                        * Field[] getFields() :获取所有public修饰的成员变量
                        * Field getField(String name)   获取指定名称的 public修饰的成员变量

                        * Field[] getDeclaredFields()  获取所有的成员变量,不考虑修饰符
                        * Field getDeclaredField(String name)  
                2. 获取构造方法们
                        * Constructor<?>[] getConstructors()  
                        * Constructor<T> getConstructor(类<?>... parameterTypes)  

                        * Constructor<T> getDeclaredConstructor(类<?>... parameterTypes)  
                        * Constructor<?>[] getDeclaredConstructors()  
                3. 获取成员方法们:
                        * Method[] getMethods()  
                        * Method getMethod(String name, 类<?>... parameterTypes)  

                        * Method[] getDeclaredMethods()  
                        * Method getDeclaredMethod(String name, 类<?>... parameterTypes)  

                4. 获取全类名       
                        * String getName()  

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马