One interface can inherit another interface with the keyword extends.
interface IntefaceA {
void meth1();
void meth2();
}
interface IntefaceB extends IntefaceA {
void meth3();
}
class MyClass implements IntefaceB {
public void meth1() {
System.out.println("Implement meth1().");
}
public void meth2() {
System.out.println("Implement meth2().");
}
public void meth3() {
System.out.println("Implement meth3().");
}
}
public class Main {
public static void main(String arg[]) {
MyClass ob = new MyClass();
ob.meth1();
ob.meth2();
ob.meth3();
}
}
The output:
Implement meth1().
Implement meth2().
Implement meth3().
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |