I am reading the newly released Java 8 in Action and found there is a piece of code pasted from Chapter 5 not compiling:
List numbers1 = A
First, correcting your terminology: when you say syntax sugar, what you really are asking about is type inference, that when asked to infer a type for j
in the inner lambda, that the compiler fails to come up with the right type.
Second, correcting your data: The error messages you cite are not coming from the JDK compiler; they're coming from Eclipse.
This is just an Eclipse bug. The reference compiler (javac
from Oracle JDK) handles your first example just fine.