Last active
February 22, 2018 15:38
-
-
Save Artemas-Muzanenhamo/3d73945ea2bc0b1614ff6f427b984412 to your computer and use it in GitHub Desktop.
This is a simple gist to show the minimal requirements to create a lambda in Java 8+
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
/** | |
* Lambdas require a Functional Interface and | |
* a target method | |
* | |
*/ | |
public class Example { | |
public static void main(String[] args) { | |
Summation summation = (a, b) -> a + b; | |
System.out.println(summation.sum(3, 4)); | |
} | |
} | |
@FunctionalInterface | |
interface Summation { | |
// target method | |
int sum(int n, int m); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment