Collectors.toList() vs. Stream.toList() #java #shorts #coding #airhacks

preview_player
Показать описание

Java used in this short: openjdk version "21" 2023-09-19 LTS

#airhacks
Рекомендации по теме
Комментарии
Автор

Yeah this had me confused 3 months ago haha

Lukas-vxfr
Автор

This Design desicion is horrible.
Given you work on a lib and change your collectors (like sonar will advice you).
Now you`re changing the behavior without the Client beeing able to check this at compile time.
Don`t ask me how i know.

stephansinger
Автор

Collectors.toXXX - List, Set, Map are mutables and Stream.toXXX - List, Set, Map are immutables

vivekravi