News for hackers. Stuff that matters.
Re:Hidden Features of Java by chrisbroadfoot on Monday January 09, 2012 @08:29AM (#3442403)
Why not

  Arrays.asList("apple", "orange", "pear")
Re:Hidden Features of Java by eneveu on Tuesday January 10, 2012 @07:15PM (#3449809)
I personally prefer Guava's immutable collections:

    List<String> fruits = ImmutableList.of("apple", "orange", "pear");
It also works for sets and maps:

    Set<String> fruits = ImmutableSet.of("apple", "orange", "pear");
    Map<String, Integer> fruitCounts = ImmutableMap.of("apple", 3, "orange", 2, "pear", 6);

http://code.google.com/p/guava-libraries/wiki/ImmutableColle...
Re:Hidden Features of Java by 6ren on Tuesday January 10, 2012 @06:31AM (#3446567)
You save "" for each extra item, which gets annoying on longer lists.