Lambda expression not working with IntelliJ
10,921
Solution 1
Change the project language level to 10:
Solution 2
On your application folder build.gradle Add compileOptions inside android:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_10
targetCompatibility JavaVersion.VERSION_1_10
}
}
Author by
Tyler James
Updated on June 05, 2022Comments
-
Tyler James almost 2 years
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
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")); } }
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?