The Artima Developer Community
Sponsored Link

Java Buzz Forum
Collection shortcuts

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Chris Winters

Posts: 931
Nickname: cwinters
Registered: Jul, 2003

Daytime: Java hacker; nighttime: Perl hacker; sleeptime: some of both.
Collection shortcuts Posted: Jan 18, 2005 11:40 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Chris Winters.
Original Post: Collection shortcuts
Feed Title: cwinters.com
Feed URL: http://www.cwinters.com/search/registrar.php?domain=jroller.com®istrar=sedopark
Feed Description: Chris Winters on Java, programming and technology, usually in that order.
Latest Java Buzz Posts
Latest Java Buzz Posts by Chris Winters
Latest Posts From cwinters.com

Advertisement
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 = 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.

Read: Collection shortcuts

Topic: New Apple stuff Previous Topic   Next Topic Topic: Free Throwaway Email Addresses

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use