Skip to content

Instantly share code, notes, and snippets.

@lol97
Created January 21, 2024 14:46
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 lol97/51421fe0cb236b76e1341e9f539cd125 to your computer and use it in GitHub Desktop.
Save lol97/51421fe0cb236b76e1341e9f539cd125 to your computer and use it in GitHub Desktop.
public class GameLambda {
interface Clickable {
void onClick();
}
private Clickable action;
void setClickAction(Clickable action) {
this.action = action;
}
void handleClick() {
action.onClick();
}
public static void main(String[] args) {
GameLambda reference = new GameLambda();
reference.setClickAction(new Clickable() {
@Override
public void onClick() {
// TODO Auto-generated method stub
System.out.println("handle href from data internal");
}
});
reference.handleClick();
GameLambda lambda = new GameLambda();
lambda.setClickAction(() -> {
System.out.println("come hereee ");
});
lambda.handleClick();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment