如何在java 1.7中编写此行
client.getIndex("users").saveObjectAsync(j, user.getKey(), (jsonObject, e)->{});
答案 0 :(得分:1)
正如@yshavit所说,你必须用单方法接口的匿名类替换lambda表达式。
interface LambdaReplacement {
void someMethod(SomeJsonType jsonObject, AMysteriousE e);
}
当然你需要知道函数的2个输入的类型;)
然后在你的代码中
client.getIndex("users").saveObjectAsync(j, user.getKey(), new LambdaReplacement() {
@Override
public void someMethod(SomeJsonType jsonObject, AMysteriousE e) {
// whatever you want to actually do with it
// or just nothing if you really want the behavior (jsonObject, e)->{}
}
});