Java Class getMethod() 方法

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

java.lang.Class 类的 getGenericSuperClass() 方法返回一个方法对象,该对象表示此 Class 对象所表示的类或接口的指定公共成员方法。name 参数作为字符串传递。

语法

参数

name - 方法的名称

parameterTypes - 参数列表

返回值

Method 对象。

抛出

NoSuchMethodException , NullPointerException , SecurityException

示例 1

输出

method = public java.lang.Integer ClassgetMethodExample1.showMethod()
method = public void ClassgetMethodExample1.showLongMethod(java.lang.Long)

示例 2

输出

public int ClassgetMethodExample2.IntCalc(int)
public void ClassgetMethodExample2.Work()
public static void ClassgetMethodExample2.StaticMethod(java.lang.String)
public void ClassgetMethodExample2.Work()
 
下一个主题Java类