Created
May 1, 2013 06:38
-
-
Save imZack/5494037 to your computer and use it in GitHub Desktop.
Interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Htc { | |
public String name; | |
public Action action ; | |
public Htc(Action action) { | |
this.action = action; | |
} | |
} | |
interface Action { | |
void doWalk(); | |
} | |
public class Test { | |
public static void main(String[] args) { | |
Htc htc1 = new Htc(new Action(){ | |
public void doWalk() { | |
System.out.println("Dog is walking"); | |
} | |
}); | |
Htc htc2 = new Htc(new Action(){ | |
public void doWalk() { | |
System.out.println("Cat is walking"); | |
} | |
}); | |
htc1.action.doWalk(); | |
htc2.action.doWalk(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment