News for hackers. Stuff that matters.
Re:Java 7 - What's new? Release date, code examples and perf... by abalashov on Sunday April 11, 2010 @08:20PM (#1258012)
Why does it only return immutable collections? Because the spec says so, or because there is some principle suggesting that it should?

Personally, my first instinct was to read the syntax as a form of initialisation, not something that would bar me from adding or deleting elements after the set is instantiated.

Re:Java 7 - What's new? Release date, code examples and perf... by extension on Sunday April 11, 2010 @11:46PM (#1258354)
Because it solves the problem mentioned above i.e. the compiler's choice of which type of container to create becomes straightforward.
Re:Java 7 - What's new? Release date, code examples and perf... by sesqu on Monday April 12, 2010 @06:13AM (#1258819)
If the choice would be a mutable one, making it expressly immutable after the fact serves no purpose. As it is, the compiler gets to choose an efficient list for the data provided, and then refuse to compromise on that efficiency later. You might as well use an enum. What useful collection implementation would require immutability? Even arrays are more flexible.

Sure, it's nice syntax, but I can come up with more scenarios where I'll want to initialize a collection than scenarios where I want to finalize one (well, excepting for the fact that this is java, where immutability is often considered a virtue).