Grokking Java Interview Questions
Vote

0% completed

​

Unmodifiable, Immutable, and Synchronized Collections

Java offers three common ways to obtain a list that rejects add(): List.of(), Collections.unmodifiableList(), and Arrays.asList(). The three results are not the same kind of list. One of them still accepts set(), one shows changes that other code makes later, and only one is a list that no code can change.

The four questions below separate these three lists, define what immutable means for a collection, compare the maps that several threads can share, and end with a method for choosing a collection.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content