2011-07-06 54 views
2

今天我在代码中发现了什么似乎是实现父类已经继承的接口的子类。实现通用接口的父类和子类重复

我可以知道这是否有任何不良副作用或意图,因为我正在努力将其从儿童课堂中删除,因为我认为这可能是一个意外的错误,或者我可能错过了什么?

在子类:

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

+1

也在这里回答:http://stackoverflow.com/questions/5668429/why-would-both-a-parent-and-child-class-implement-the-same-interface。 –

回答

3

删除implements javax.ejb.SessionBeanProductServiceBean类不会有任何影响,因为该类实现的接口从父GenericSessionBean类继承的事实。

将它包含在子类中也没有任何坏处,它只是一个冗余声明。

3

让孩子和父母都实现相同的接口没有其他影响。这相当于让父母仅实现该接口。