- interface IntefaceA {
- void methodA();
- int methodC();
- }
- interface IntefaceB {
- void methodB();
- boolean methodC();
- }
- class ClassAB implements IntefaceA,IntefaceB {
- public void methodB() {
- System.out.println("methodA");
- }
- public void methodA() {
- System.out.println("methodB");
- }
- public int methodC()
- {
- System.out.println("methodAC");
- }
- public boolean methodC()
- {
- System.out.println("methodBC");
- }
- public static void main(String[] args) {
- IntefaceA a = new ClassAB();
- a.methodA();
- a.methodC();
- IntefaceB b = new ClassAB();
- b.methodB();
- b.methodC();
- }
- }
复制代码 运行结果是
编译失败,可见是不能这么做的 |