1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
package com.example; import java.util.function.Function; public class Lambda { public static int value(int factor) { return new Lambda(factor).run(); } private final int factor; private Lambda(int factor) { this.factor = factor; } private int run() { IntFunction function = value -> value * factor; return function.apply(21); } }