Most probably a duplicate, however I was not able to find any particular one.
Given
public static void main(String[] args) {
System.out.println(
Arrays.asList(null, null, 1)
.stream()
.filter(obj -> obj == null)
.findAny()
.isPresent()
);
}
Expectation
Should at least work (i.e return false because findAny returns Optional).
Actual
NullPointerException is thrown
Question
Is it a bug or a feature?
Thanks for your opinion and explanation.