如何调用类层次结构中的方法?
我有一个从另一个类扩展的超类
public abstract class AbstractDOEMessageFinderAction extends BasicObjectFinder {
public Object performBasicSearch() {
// works fine because getQuery is defined in BasicObjectFinder
return getQuery();
}
另一个类是 ISIRFinderAction
,它扩展自 AbstractDOEMessageDashboardAction
ISIRFinderAction extends AbstractDOEMessageDashboardAction {
// My aim is to make sure this method works so that I will make
// the super class's performBasicSearch() method abstract.
public Object performBasicSearch() {
// this one doesnt even compile but it extends AbstractDOEMessageDashboardAction
// which in turn extends BasicObjectFinder
return getQuery();
}
}
我错过了什么吗?为什么 getQuery
不起作用。我认为它会在类层次结构中搜索它。
I have this super class which extends from another class
public abstract class AbstractDOEMessageFinderAction extends BasicObjectFinder {
public Object performBasicSearch() {
// works fine because getQuery is defined in BasicObjectFinder
return getQuery();
}
The other class is ISIRFinderAction
which extends from AbstractDOEMessageDashboardAction
ISIRFinderAction extends AbstractDOEMessageDashboardAction {
// My aim is to make sure this method works so that I will make
// the super class's performBasicSearch() method abstract.
public Object performBasicSearch() {
// this one doesnt even compile but it extends AbstractDOEMessageDashboardAction
// which in turn extends BasicObjectFinder
return getQuery();
}
}
Am I missing something? Why is getQuery
not working. I thought it would search it in the class hierarchy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第二个类扩展了
AbstractDOEMessageDashboardAction
而不是AbstractDOEMessageFinderAction
。The second class extends
AbstractDOEMessageDashboardAction
notAbstractDOEMessageFinderAction
.AbstractDOEMessageDashboardAction
是否也扩展了BasicObjectFinder
?(请注意,
AbstractDOEMessageDashboardAction
当然与AbstractDOEMessageFinderAction
不同)。Does
AbstractDOEMessageDashboardAction
also extendBasicObjectFinder
?(Note,
AbstractDOEMessageDashboardAction
is ofcourse not the same asAbstractDOEMessageFinderAction
).