Java Class getDeclaredMethods() 方法

2025 年 3 月 21 日 | 阅读 2 分钟

java Class 类的 getDeclaredMethods() 方法返回一个表示此类对象中所有已声明方法的 method 对象数组。如果没有声明方法,则返回一个长度为 0 的数组。

语法

参数

不适用

返回值

一个 method 对象数组。

抛出

安全异常

示例 1

输出

Method (1)public static void ClassgetDeclaredMethodsExample1.main(java.lang.String[])
Method (2)public void ClassgetDeclaredMethodsExample1.showIntegermethod(java.lang.Integer)
Method (3)private java.lang.Integer ClassgetDeclaredMethodsExample1.showmethod()
Method (4)public void ClassgetDeclaredMethodsExample1.showFloatmethod(float)

示例 2

输出

Method (1)private void ClassgetDeclaredMethodsExample2$Sample1.Method1()
Method (2)public void ClassgetDeclaredMethodsExample2$Sample1.Methodint(int)
 
下一个主题Java类