// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.util.function.Consumer;
import java.util.function.Function;

public class Lambda {
    public static void test1(Function<Integer, Integer> f, int x) {
        System.out.println(f.apply(x));
    }
    public static void test2(FuncSig f, int a, int b) {
        System.out.println(f.eval(a, b));
    }
    public static void test3(Consumer<String> f, String s) {
        f.accept(s);
    }
    public static void main(String[] args) {
        test1(x -> x+x, 5);
        test1(x -> x*x, 5);
        test2((a,b) -> a+b, 123, 456);
        FuncSig fs = (a,b) -> a+b;
        test2(fs, 123, 456);
        test3(System.out::println, "ABC");
    }
}

@FunctionalInterface
interface FuncSig {
    public int eval(int a, int b);
}
