Skip to content

Instantly share code, notes, and snippets.

@chao2zhang
Last active November 26, 2019 07:50
Show Gist options
  • Save chao2zhang/3cb92ddf079dd1f368ec306d0963cbdc to your computer and use it in GitHub Desktop.
Save chao2zhang/3cb92ddf079dd1f368ec306d0963cbdc to your computer and use it in GitHub Desktop.
// JavaApp.java
private boolean isEven(int id) {
return id % 2 == 0;
}
public boolean invokeJavaSam(int id, JavaSam sam) {
return sam.apply(id);
}
private void useJavaSam() {
JavaSam javaSam = id -> id % 2 == 0;
invokeJavaSam(3, id -> id % 2 == 0);
invokeJavaSam(4, this::isEven);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment