Listlist = new ArrayList ();
list.add(Integer.valueOf(1));
list.add(Integer.valueOf(2));
list.add(Integer.valueOf(3));
Well, thanks to autoboxing and varargs, you can do this instead:
Listlist = Arrays.asList(1, 2, 3);
Sure, it's not a huge deal, but it's just better in every sense of the word.
3 comments:
list = [1, 2, 3]
One should know that the resulting ArrayList is kind of weak. For instance ... íf you like to remove from it you'll get a UnsupportedOperationException. Another wrap solves that issue (i.e. new ArrayList(Arrays.asList ... ) but now thing does not look quite as nice anymore. :(
/Tobias
(but that has nothing to do with Tiger of course)
Post a Comment