I'm trying out the following code and compiling it using JDK 1.8.0_66. My code seems to be syntactically correct, did I miss something?
interface Executable {
void execute();
}
class Runner {
public void run(Executable e) {
System.out.println("Executing code block!");
e.execute();
}
}
public class HelloWorld {
public static void main(String[] args) {
Runner runner = new Runner();
runner.run(new Executable() {
public void execute() {
System.out.println("IN ANONYMOUS CLASS EXECUTE");
}
});
}
runner.run(() -> System.out.println());
}
throws the following compile error:
App.java:25: error: <identifier> expected
runner.run(() -> System.out.println());
^
App.java:25: error: illegal start of type
runner.run(() -> System.out.println());
^
App.java:25: error: ';' expected
runner.run(() -> System.out.println());