Skip to content

Instantly share code, notes, and snippets.

@antic183
Last active December 16, 2017 12:45
Show Gist options
  • Save antic183/1b2a80ccd075b79f74dc8c8b7b1c670a to your computer and use it in GitHub Desktop.
Save antic183/1b2a80ccd075b79f74dc8c8b7b1c670a to your computer and use it in GitHub Desktop.
java 8 lambda example
@java.lang.FunctionalInterface
interface Math
{
public int calc(int a, int b);
}
public class LambdaExample
{
public static void main(String[] args) {
// define your function
Math add = (a, b) -> a+b;
// execute it later (by event)
int res = add.calc(7, 5);
System.out.println(res); //12
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment