Skip to content

Instantly share code, notes, and snippets.

@bitlather
Created November 13, 2017 14:25
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 bitlather/b3f389c1e49d3b0869e141370a6c3e61 to your computer and use it in GitHub Desktop.
Save bitlather/b3f389c1e49d3b0869e141370a6c3e61 to your computer and use it in GitHub Desktop.
public class Lambda { // requires >= java 1.8
interface IntegerMath {
int operation(int a, int b);
default IntegerMath swap() {
return (a, b) -> operation(b, a);
}
}
public static void main(String[] args) {
IntegerMath addition = (a, b) -> a + b;
System.out.println(addition.operation(40, 2));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment