I really wish they hadn't implemented "immutable" lists as a normal List that throws unchecked exceptions on modification.
Would it have been that hard to add a ReadOnlyList interface with only the methods that don't throw? Now we've got a wonky compile-unsafe toList() in the standard library for all time.
Or perhaps they could implement it like String. String has mutators but they don’t change the original value. To get the modified one, assign it to another variable. Another example is the collection framework of vavr.
65
u/[deleted] Mar 16 '21
Finally I can start migrating from
.collect(Collectors.toList())totoList()