pus*_*hpa 1 java lambda functional-programming functional-interface
我们应该如何称呼存储该功能接口的实现的对象呢?将其称为匿名类是否正确?
功能接口定义
@FunctionalInterface
interface IntBinaryOperator {
int applyAsInt(int left, int right);
}
Run Code Online (Sandbox Code Playgroud)
用于实现功能接口的测试类
public class Lambdas {
public static void main(String[] args) {
IntBinaryOperator multiply = (a, b) -> a * b; // what is this object called?
System.out.println(multiply.applyAsInt(2,3));
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
61 次 |
| 最近记录: |