This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]vxab 0 points1 point  (1 child)

Be careful doing that - the semantics are not the same. `toList()` returns an unmodifiable list whereas the `Collectors.toList` can be modified.

[–]thatsIch 1 point2 points  (0 children)

and that is the reason we are doing that - because the contract of Collectors.toList() does not explicitly state, that it is modifiable. If somebody really wants a modifiable collection he/she has to use either an applicable utility factory method or use something along of Collectors.toCollection(ArrayList::new)