Last active
December 16, 2017 12:45
-
-
Save antic183/1b2a80ccd075b79f74dc8c8b7b1c670a to your computer and use it in GitHub Desktop.
java 8 lambda example
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
@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