Mega Code Archive

 
Categories / Java Tutorial / Class Definition
 

Interfaces and Polymorphism

interface ThisInterface {   public void thisMethod(); } interface ThatInterface {   public void thatMethod(); } class MyClass implements ThisInterface, ThatInterface {   // Class definition including methods from both interfaces...   public void thisMethod() {     System.out.println("this");   }   public void thatMethod() {     System.out.println("that");   } } public class MainClass {   public static void main(String[] a) {     MyClass cls = new MyClass();     cls.thisMethod();     cls.thatMethod();   } } this that