【发布时间】:2018-01-06 01:21:53
【问题描述】:
public Method[] getDeclaredMethods() throws SecurityException
有如下文档。
/**
*
* Returns an array containing {@code Method} objects reflecting all the
* declared methods of the class or interface represented by this {@code
* Class} object, including public, protected, default (package)
* access, and private methods, but excluding inherited methods.
<p> If this {@code Class} object represents a type that has multiple
* declared methods with the same name and parameter types, but different
* return types, then the returned array has a {@code Method} object for
* each such method.
*
一个类怎么可能有两个 [已声明] 方法具有不同的返回类型、相同的名称和相同的参数类型?
【问题讨论】:
-
不是叫
overloading吗? -
@Shark 要重载方法必须有不同的签名。
-
你可能想看看这个问题:stackoverflow.com/q/2801878/8116173
标签: java reflection