2011-09-15 79 views
0

有2個接口A和B實現遠程方法。我怎樣才能實現聚合接口A和B的另一個接口?或者還有其他方法可以做到嗎? 如:遠程接口的UML類圖

public interface A extends java.rmi.Remote 
{ 
    //function declns 
} 

public interface B extends java.rmi.Remote 
{ 
    //function declns 
} 

public interface C extends java.rmi.Remote implements A,B 
{ 
} 

給了我錯誤說有關於農具

請幫助

回答

1
public interface A extends java.rmi.Remote 
{ 
    //function declns 
} 

public interface B extends java.rmi.Remote 
{ 
    //function declns 
} 

public interface C extends A,B 
{ 
} 

注意接口C不需要直接擴展java.rmi.Remote,因爲它延伸的語法錯誤AB,兩者本身直接延伸Remote

2
public interface A { 
    public methodA(); 
} 

public interface B { 
    public methodB(); 
} 

public interface C implements A,B { 
    public methodA(); 
    public methodB(); 
} 


+----+  +-----+ 
| A |  | B | 
+----+  +-----+ 
^  ^
    |   | 
+----------------+ 
|  C  | 
+----------------+