Last active
July 26, 2019 19:26
-
-
Save viniciusd/65658d7635aead8de825ce641ce1c832 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.util.function.Function; | |
public class MyClass { | |
private static Function<Integer,Integer> outside(Integer y) { | |
return new Function<Integer, Integer>() { | |
@Override | |
public Integer apply(Integer x) { | |
return x + y; | |
} | |
}; | |
} | |
private static Function<Integer,Integer> outside_lambda(Integer y) { | |
return (x) -> (y + x); | |
} | |
public static void main(String args[]) { | |
int x=10; | |
int y=25; | |
Function<Integer,Integer> inner_fn = outside(new Integer(y)); | |
int z = inner_fn.apply(x).intValue(); | |
System.out.println("Sum of x+y = " + z); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment