Warm tip: This article is reproduced from serverfault.com, please click

Lambda expression not working with IntelliJ

发布于 2018-05-21 05:34:17

Im trying to use the IntelliJ IDE to write a JavaFX program, however when the lambda expression is used, I get an error message followed by a compile error

original code
error message

Overrides method in javafx.event.EventHandler

package sample;

import javafx.application.Application
import javafx.scene.control.*;
import javafx.stage.Stage;

public class Main extends Application {


public static void main(String[] args) {
    launch(args);
}

@Override
public void start(Stage window) throws Exception {

    window.setTitle("Window Title");
    Button button = new Button("Click me");
    button.setOnAction(e -> System.out.println("Hello World"));

    }


}

compile error

To specify, it is set up as a JavaFX program, in project structure I have the Project SDK set to 10.0.1 and I have the language level set to 8
Is there something missing that I need in order to use lambda expressions?

Questioner
Tyler James
Viewed
0
CrazyCoder 2018-05-21 13:58:52

Change the project language level to 10:

language level