Hacker News new | ask | show | jobs
by rtg 5437 days ago
If you use the Google library [1], this becomes a bit more convenient that the built-in Java way:

   List<String> people = ImmutableList.of("Frank", "Mary", "Bob");
There's also ImmutableSet and many other goodies, to say the least. For instantiation of these generic types, you can do:

   List<String> people = Lists.newArrayList(); 
   Map<String,Integer> scores = Maps.newHashMap();
and so on.

[1] http://code.google.com/p/guava-libraries/

1 comments

Since 1.5 you can use the `Arrays` built-in [1]:

    List<String> people = Arrays.asList("Frank", "Mary", "Bob");

[1] http://download.oracle.com/javase/1.5.0/docs/api/java/util/A...