...
In Java 9, Map.of and Set.of were introduced. These are static factory methods which take values on the fly and return Unmodifiable mapsmap/sets set which contain those values. These unmodifiable map/set are immutable as they do not have a mutable map/set which can be accessed to modify the values within the map/set.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
Map<String, String> immutableMap = Map.of("A", "Apple", "B", "Ball", "C", "Car") |
...