Skip to main content

Basic forEach not compiling

No replies
ewan123
Offline
Joined: 2013-05-08
Points: 0

Does anyone know why this won't compile?

List numbers = Arrays.asList(1, 2, 3, 4, 5);
numbers.forEach(s -> { System.out.println(s); });

Error:
ListTest.java:8: error: cannot find symbol
numbers.forEach(s -> { System.out.println(s); });
^
symbol: method forEach((s)->{ Sys[...]s); })
location: variable numbers of type List
1 error

using

java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b86)