list literal gotcha and suggestion

Paul Benedict pbenedict at apache.org
Tue Oct 6 10:43:58 PDT 2009


Some of the examples below are bogus. But the point being, that the
compiler will still err when conversion is impossible -- rather
implicit or explicit.

On Tue, Oct 6, 2009 at 12:42 PM, Paul Benedict <pbenedict at apache.org> wrote:
> The obvious implication here is the need for a type-cast:
>
> System.out.println((List<>){{1, "One"}, {2, "Two"}});
> or
> System.out.println((Set<>){{1, "One"}, {2, "Two"}});
> or
> System.out.println((Map<>){{1, "One"}, {2, "Two"}});
>
> This fits naturally with current Java expectations to resolve ambiguity.
>
> Paul
>



More information about the coin-dev mailing list