如何在 Java 中使用 lambda 表达式实现 ToIntBiFunction ?
ToIntBiFunction
语法
@FunctionalInterface interface ToIntBiFunction{ int applyAsInt(T t, U u); }
示例
import java.util.function.ToIntBiFunction; public class ToIntBiFunctionTest { public static void main(String args[]) { ToIntBiFunction输出结果test = (t, u) -> t * u; System.out.println("t和u的乘积为: " + test.applyAsInt(10, 7)); System.out.println("t和u的乘积为: " + test.applyAsInt(8, 15)); } }
t和u的乘积为: 70 t和u的乘积为: 120