In python, those give a mutable set, which is what I was referring to above.
Also not to put too a fine a point, you'll never see python code like that in the wild, but even in code reviews these days, it's common to find Java code written like in my example because the syntax for sets in Java came after Java 8
My bad on the mutability. As far as code like that written in Java, I don't think I've ever seen something like that in anything non-toy and I started with Java 7.
I think that's fair. As with good UI, I appreciate when I can navigate via intuition. The solution in Python is intuitive, readable, and memorable. When working in Java, I frequently felt compelled to read and review pages of docs in search of a straightforward solution. I'm a sucker for Python's syntactic sugar.
I've never seen a language have a single way to do something. It's part of Python's mission statement, but it doesn't appear to even have been a consideration in practice.
In python you can also do
and 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.