Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

lachoy (1663)


I am actually Chris Winters; I am actually living in Pittsburgh, Pennsylvania, USA; I am actually married and have three cats. (Guess what one of them is named?) I am the "OpenInteract" guy, which could be good or bad.

Journal of lachoy (1663)

Tuesday January 18, 2005
01:06 PM

Collection shortcuts

[ #22775 ]
Arrays.asList("Rod", "Jane", "Freddy"); - Dion points out the shortcut to creating a List. One of the libraries I always have handy does this for Maps and Sets too, so you can do:

Map m = new String[] { "foo", "bar", "baz", "blargle" } );

Not as nice as the Rhino or Groovy (or Perl!) versions, but still handy. (Java's lack of shortcuts for stuff like this is really frustrating, although the varargs in 1.5 should make this simpler.) If you implement this yourself I recommend using LinkedHashMap as an implementation so you get the keys back in the same order you inserted them.

Posted from; read original

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.