«« Next » « Previous
«« Next » « Previous

Link Details

Link 90900 thumbnail
User 214988 avatar

By puredanger
via coderoshi.com
Published: Jun 29 2008 / 02:14

Here's another cheap trick around reducing the common need for a static block populated list
  • 13
  • 5
  • 2025
  • 659

Comments

Add your comment
User 261293 avatar

joecoder replied ago:

0 votes Vote down Vote up Reply

The article suggests writing utilities that already exist in the Java library.

User 107114 avatar

daniel replied ago:

0 votes Vote down Vote up Reply

It's true, these methods do exist already. (Arrays.asList(...), for example)

User 204894 avatar

arikthered replied ago:

0 votes Vote down Vote up Reply

Yes, asList does - that's why I took it out. The Set and Map versions don't - however.

User 261293 avatar

joecoder replied ago:

0 votes Vote down Vote up Reply

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.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.