list literal gotcha and suggestion
gkbrown at mac.com
Wed Sep 30 12:38:28 PDT 2009
> But this doesn't work:
> List<Integer> list = new ArrayList<Integer>(1);
> So it has to be something like Collections.list() (the result of
> Arrays.asList() can't grow).
You are right. My original suggestion was actually to add a varargs
version of unmodifiableList(), etc. (see http://mail.openjdk.java.net/pipermail/coin-dev/2009-July/002097.html
List<Integer> list = ArrayList.unmodifiableList(1, 2, 3);
Set<String> set = HashSet.unmodifiableSet("a", "b", "c");
But varargs constructors would be handy as well.
More information about the coin-dev