I'm studying the factory methods for Immutable collections.
I see the Set.of() method has 10 varargs overloading (same for Map.of()). I really can't understand why there are so many. In the end the function ImmutableCollections.SetN<>(elements) gets called anyway.
In the documentation I found this:
While this introduces some clutter in the API, it avoids array allocation, initialization, and garbage collection overhead that is incurred by varargs calls.
Is the clutter indeed worth the performance gain? If yes, would that ideally do create a separate method for any N elements?