Skip to content

Instantly share code, notes, and snippets.

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