我有以下代码:
public interface Listener {
void onRemoved(int position);
void onAdded();
}
我的类(class):
/* constructor */
public Test(Listener listener) {}
另一个类:
Test test = new Test(How to implement the onRemoved and onAdded here using lambda?)
最佳答案
在java8中lambda被用来实现Functional Interfaces因此根据定义它必须包含仅一个抽象方法 - 因此答案是你不能。
您需要的是 Anonymous Class实例
关于java - 如何使用lambda在构造函数参数中实现 > 1 接口(interface)方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57354813/