Map m = StructUtil.map( 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 cwinters.com; read original
Collection shortcuts 0 Comments More | Login | Reply /