开发者

What class parameter type should should be passed for variable arg Object array

If I have to pass an Object... var arguments parameter as input 开发者_高级运维to the Method.invoke call, what should I specify as the parameter type for the Class.getMethod call


Class.getMethod("methodName", Object[].class)

UPDATE How to work with varargs and reflection provides more precise answer by Bozho


You're best off if you can specify the Classes that represent the real formal parameters of the method, as in its declaration. If you can't, the rules for resolution (at the link you provide) are not the most transparent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜