【发布时间】:2009-10-26 22:18:37
【问题描述】:
我正在尝试调用一个方法,该方法将超类作为参数,实例中有子类。
public String methodtobeinvoked(Collection<String> collection);
现在如果通过调用
List<String> list = new ArrayList();
String methodName = "methodtobeinvoked";
...
method = someObject.getMethod(methodName,new Object[]{list});
没有这样的方法异常会失败
SomeObject.methodtobeinvoked(java.util.ArrayList);
即使存在可以接受参数的方法。
对解决此问题的最佳方法有什么想法吗?
【问题讨论】:
-
不需要重载;请看看我的更新。
标签: java methods subclass invoke superclass