1. create the dynamic instance for what ?
- for get the methods , fields ,constructors ....
2. if the modifers of the method is private/protected , will the method be reflected ?
- getMethod ---Returns a
Methodobject that reflects the specified public member method of the class or interface represented by thisClassobject. - getDeclaredMethods ---Returns an array of
Methodobjects reflecting all the methods declared by the class or interface represented by thisClassobject. This includes public, protected, default (package) access, and private methods, but excludes inherited methods. - it is the same as to fileds
3.what i learned since now :
- what is reflect in java
- what can reflect do in java
- how to get an instance and the constructors ,methods ,fields through reflect to have a good knowledge of the class which been reflect .
- advantage and disadvantage (low performance ,may be make the program more complex)
- example : dymaic invoke
4. java.lang.Array 类提供了动态创建和访问数组元素的各种静态方法
5.
article :
本文深入探讨Java反射机制的基础概念及其实用场景,包括如何通过反射创建动态实例、获取类的构造器、方法和字段等。此外,还分析了反射操作的权限限制以及其优缺点,并给出了一些实际应用案例。
904

被折叠的 条评论
为什么被折叠?



