Skip to content

Instantly share code, notes, and snippets.

@imZack
Created May 1, 2013 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imZack/5494037 to your computer and use it in GitHub Desktop.
Save imZack/5494037 to your computer and use it in GitHub Desktop.
Interface
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