Arrays.asList() is effective for initializing sets too (using the constructor that takes a Collection) and the technique is not specific to a specific set implementation (such as HashSet in the article's examples). The map initialization is potentially useful. If the article had focussed on that I'd have voted it up.
Comments
joecoder replied ago:
The article suggests writing utilities that already exist in the Java library.
daniel replied ago:
It's true, these methods do exist already. (Arrays.asList(...), for example)
arikthered replied ago:
Yes, asList does - that's why I took it out. The Set and Map versions don't - however.
joecoder replied ago:
Arrays.asList() is effective for initializing sets too (using the constructor that takes a Collection) and the technique is not specific to a specific set implementation (such as HashSet in the article's examples). The map initialization is potentially useful. If the article had focussed on that I'd have voted it up.
Voters For This Link (13)
Voters Against This Link (5)