list literal gotcha and suggestion

Greg Brown gkbrown at
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 

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 mailing list