Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package polymophism;
  2.  
  3. public interface Action {
  4.     public void eat();
  5.  
  6. }
  7.  
  8. public class Man implements Action {
  9.     public void eat() {
  10.         System.out.println("Man eat");
  11.     }
  12. }
  13.  
  14. public class Woman implements Action {
  15.  
  16.     public void eat() {
  17.         System.out.println("Woman eat");
  18.     }
  19.  
  20. }
  21.  
  22. public class Tester {
  23.  
  24.     public static void main(String[] args) {
  25.         Woman w = new Woman();
  26.         Man m = new Man();
  27.         Tester tester = new Tester();
  28.         tester.eat(m);
  29.         tester.eat(w);
  30.     }
  31.  
  32.     private void eat(Action h) {
  33.         h.eat();
  34.     }
  35.  
  36. }