- import java.util.function.Function;
- static Function<Integer,Void> f (int x) {
- Function<Integer,Void> g = new Function<Integer,Void>() {
- public Void apply(Integer y) {
- System.out.format ("x = %d, y = %d%n", x, y);
- return null;
- }
- };
- g.apply (1);
- return g;
- }
- public static void main (String[] args) {
- Function<Integer,Void> h = f (10);
- h.apply (2);
- f (20);
- h.apply (3);
- }