list literal gotcha and suggestion

Paul Benedict pbenedict at
Tue Oct 6 10:42:42 PDT 2009

The obvious implication here is the need for a type-cast:

System.out.println((List<>){{1, "One"}, {2, "Two"}});
System.out.println((Set<>){{1, "One"}, {2, "Two"}});
System.out.println((Map<>){{1, "One"}, {2, "Two"}});

This fits naturally with current Java expectations to resolve ambiguity.


On Tue, Oct 6, 2009 at 12:38 PM, Neal Gafter <neal at> wrote:
> On Tue, Oct 6, 2009 at 9:45 AM, Reinier Zwitserloot
> <reinier at> wrote:
>> Nobody has yet answered my original question:
>> What does:
>> System.out.println({{1, "One"}, {2, "Two"}});
>> print? Looking at visual basic for syntax advice is not a good idea.
> I suggest that it be a compile-time error because the initializer isn't
> converted to some appropriate collection type in the source.

More information about the coin-dev mailing list