我想知道两种平面图之间是否存在任何显着差异.
情况1:
someCollection
.stream()
.map(CollectionElement::getAnotherCollection)
.flatMap(Collection::stream);
Run Code Online (Sandbox Code Playgroud)
案例2:
someCollection
.stream()
.flatMap(element -> element.getAnotherCollection().stream());
Run Code Online (Sandbox Code Playgroud)
应该首选哪一个?在性能方面有哪些更好?