5 ms·
Regarding the conciseness of lambdas and collections, why doesn't Java offer methods such as map(), filter() etc directly in AbstractCollection? The implementat
by esfandia 9y ago
Regarding the conciseness of lambdas and collections, why doesn't Java offer methods such as map(), filter() etc directly in AbstractCollection? The implementations would then delegate to stream internally, so no need for the programmer to invoke stream(). I realize there are different kinds of streams, but having a sequential stream as a default would be useful. That would be one step closer to the Kotlin example.
- krzyk 9y agoWhy in AbstractCollection and not in Collection interface as a default method? Apart from that I still miss the fact that Iterable doesn't have a `stream()` method, it would make it much more useful in post-java8 world.
- dajohnson89 9y agomaybe backwards compatibility?
- riku_iki 9y agoHow exactly adding map() is not backwards compatible?..
- xendo 9y agoAdding methods to non-final classes is always incompatoble. If you had your own implementation of list and its interface suddenly requires new method, how should it behave?
- riku_iki 9y agomap() in AbstractCollection will obviously have some default implementation, which will be used by all child classes.