父类和子类重复实现公共接口
今天,我在代码中发现似乎是一个子类实现了父类已经继承的接口。
我可以知道这是否有任何不利的副作用或意图,因为我正在努力将其从儿童班级中删除,因为我相信这可能是一个意外错误,或者也许我错过了一些东西?
在子类中:
public class ProductServiceBean
extends GenericSessionBean
implements javax.ejb.SessionBean
在父类中:
// Compiled from GenericSessionBean.java (version 1.2 : 46.0, super bit)
public abstract class weblogic.ejb.GenericSessionBean
extends weblogic.ejb.GenericEnterpriseBean
implements javax.ejb.SessionBean
请注意,在子类和父类中,这些类都实现了 javax.ejb.SessionBean
。
Today i found in my codes what appears to be a child class implementing an interface that the parent class is already inheriting.
May i know if this has any adverse side effects or intentions, as i am working on to remove it from the child class as i believe this could have been an accidental mistake, or perhaps am i missing something?
In the child class:
public class ProductServiceBean
extends GenericSessionBean
implements javax.ejb.SessionBean
In the parent class:
// Compiled from GenericSessionBean.java (version 1.2 : 46.0, super bit)
public abstract class weblogic.ejb.GenericSessionBean
extends weblogic.ejb.GenericEnterpriseBean
implements javax.ejb.SessionBean
Note that in both child and parent, the classes do implement the javax.ejb.SessionBean
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅从
ProductServiceBean
类中删除implements javax.ejb.SessionBean
不会有任何效果,因为该类实现接口的事实是继承自父GenericSessionBean
类。将其包含在子类中也没有什么坏处,它只是一个多余的声明。
Removing
implements javax.ejb.SessionBean
from only theProductServiceBean
class will have no effect, since the fact that the class implements the interface is inherited from the parentGenericSessionBean
class.There is also no harm in including it in the child class, it's just a redundant declaration.
让子级和父级都实现相同的接口没有额外的效果。它相当于让父级仅实现该接口。
Having both the child and the parent implement the same Interface has no additional effect. It is equivalent to having the parent only implement that interface.