So assuming I use some random filter on a stream, the most straightforward way is to directly input the Predicate:
x.stream().filter(e -> e % 2 == 0)
As well I can simply make a reference and define the Predicate in advance:
Predicate<Integer> isEven = e -> e % 2 == 0;
...
x.stream().filter(isEven)
But I can as well use a function:
private static boolean isEven(Integer integer) {
return integer % 2 == 0;
}
...
x.stream().filter(MyClass::isEven)
As far as I can tell, the Predicate is of course much more limited while the function might have side effects etc. But since people like Venkat Subramaniam use the latter solution, I really wonder: What are the main differences here?