We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

RunninglVlan • 2 years ago

>These useful methods are used to create a new Non-Empty Immutable Map with 1-10 elements. The methods are designed in such a case that we can add only 10 elements to immutable List, Set, Map, and Map.Entry objects.
>If we have any requirement for an immutable collection with the size of the collection at a max of 10 or below, then we use this feature.

10 elements is true only for Map#of methods as I tested. It's just that all other methods can be written with varargs (e.g. List.of(Object... arguments)), when Map.of(key0, value0) methods can't and are written manually (e.g. there are at least 11 of them, including empty Map).