鉴于这个情况:
class MyClass {
static class A {
public boolean property() {
return Math.random() < 0.5;
}
}
static List<A> filterLambda(List<A> list) {
return list.stream().filter(a -> a.property()).collect(Collectors.toList());
}
static List<A> filterMethodCall(List<A> list) {
return list.stream().filter(A::property).collect(Collectors.toList());
}
}
- 每种方法在编译器所做的事情有何不同?
- 如果有的话,内存使用或运行时间是否有差异?(即使很小,这个问题只是学术上的)
注:我知道这个问题类似于这个问题,但我认为它没有得到正确回答。