Perhaps I’m being too critical.
In python you can also do
s = set()
s.add(1)
s.add(2)
and s = set(x for x in [1, 2])
But I wouldn't call that having three ways to do the same.Disclaimer: I don't know java well, just commenting based on the comments above and my python knowledge.