getDeclaredMethods和getMethods的区别
[getDeclaredMethods](http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html#getDeclaredMethods)
Returns an array of Method
objects reflecting all the methods declared by the class or interface represented by this Class object.
[getMethods]
(http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html#getMethods)
Returns an array containing Method
objects reflecting all the public member methods of the class or interface represented by this Class
object, including those declared by the class or interface and those inherited from superclasses and superinterfaces.
getDeclaredMethod()获取的是类自身声明的所有方法,包含public、protected和private方法。
getMethod()获取的是类的所有共有方法,这就包括自身的所有public方法,和从基类继承的、从接口实现的所有public方法。
【getDeclaredMethods和getMethods的区别】也就说调用getMethods方法输出的是自身的public方法和父类Object的public方法。调用getDeclaredMethods方法输出的是自身的public、protected、private方法。
推荐阅读
- 急于表达——往往欲速则不达
- 第三节|第三节 快乐和幸福(12)
- 20170612时间和注意力开销记录
- 2.6|2.6 Photoshop操作步骤的撤消和重做 [Ps教程]
- 对称加密和非对称加密的区别
- 眼光要放高远
- 樱花雨
- 前任
- 2020-04-07vue中Axios的封装和API接口的管理
- 烦恼和幸福