If you make use of the Java JDK 21 Preview Features in IntelliJ IDE you will see a compilation error, and also when you execute such code, you will see errors.
/Users/code2care/IdeaProjects/demo/src/Main.java:7:25
java: string templates are a preview feature and are disabled by default.
(use --enable-preview to enable string templates)
To enable preview features of Java JDK, you can follow the below step.
- Open Project Settings by pressing Command ⌘ + ; on Mac, or Ctrl+Alt+Shift+S if on Windows or Linux.
- Now for Language level: select "21 (Preview) - String templates, unnamed classes and instance main methods etc."
- You will see Experimental Feature Alert
- Close the Project Structure window.
- You will see that the complications errors are gone, and no errors in the console when you run the Java programs with preview features.
Click on Accept.

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!