代码
提交代码
import java.util.function.Function;
public class DemoFunction {
public static void main(String[] args) {
doApply(s -> Integer.parseInt(s));
doCombine(
str -> Integer.parseInt(str)+10,
i -> i *= 10
);
}
private static void doApply(Function<String, Integer> function) {
int num = function.apply("10");
System.out.println(num + 20);
}
private static void doCombine(Function<String, Integer> first, Function<Integer, Integer> second) {
int num = first.andThen(second).apply("10");
System.out.println(num + 20);
}
}
运行结果