Java Class getDeclaredMethod() 方法

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

java Class 类的 getDeclaredMethod() 方法返回一个 Method 对象,该对象表示类或接口中声明的指定方法。

语法

参数

name - 方法的名称

parameterTypes - 参数数组

返回值

Method 对象。

抛出

NoSuchMethodException , SecurityException

示例 1

输出

method  1 = private java.lang.Integer ClassgetDeclaredMethodExample1.showmethod()
method 2 = public void ClassgetDeclaredMethodExample1.showIntegermethod(java.lang.Integer)
method 3 = public void ClassgetDeclaredMethodExample1.showFloatmethod(float)

示例 2

输出

private void ClassgetDeclaredMethodExample2$Sample1.Method1()
public void ClassgetDeclaredMethodExample2$Sample1.Methodint(int)
 
下一个主题Java类