As far as I can see, the contracts of both are identical. Seems rather pointless to implement a whole new empty set for Set.of()
.
I would presume the standard library implementors are aware of Collections.emptySet()
, so there must be a specific reason I am not seeing. Due to the very generic method names, searching in mailing lists is impossible, so I am not sure if this was discussed.
(BTW, it seems Set.of()
just uses a SetN
with an empty input array, so it will probably be less efficient than emptySet()
as well.)