Created
January 21, 2024 15:01
-
-
Save lol97/225abff881383170f64b83f868b2ddf9 to your computer and use it in GitHub Desktop.
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
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