question in reading java reflect

本文深入探讨Java反射机制的基础概念及其实用场景,包括如何通过反射创建动态实例、获取类的构造器、方法和字段等。此外,还分析了反射操作的权限限制以及其优缺点,并给出了一些实际应用案例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 Method object that reflects the specified public member method of the class or interface represented by this Class object.
  •        getDeclaredMethods ---Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this Class object. 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 :

http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece7631046893b4c4380143fd3d1027fa3c215cc79010a0261e3b924211219839b21321cee0f0facab676f370324b79dcb824fddb990222488213f771f864613d212b2df037881769f18a9f45db4fca72593dfc5a3d84322cc44040a97808e4d7062dd1ff50342e9b19838022e16ad9b4172fe2960599a3430b05088eb25190196f7ad4b3dc33da463&p=cb74c54ad3c152f40be290264800&user=baidu&fm=sc&query=private+%B5%C4%B7%BD%B7%A8%C4%DC%B7%B4%C9%E4%C2%F0&qid=d0c30dfc12b5c43c&p1=1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值