Search code examples
javajava-record

How to get Java 19 to recognize 'record' keyword


I am using jdk 19 and want to make a record class for my Java project.

jdk 19

When I declare the class Person:

public record Person (String name) {}

I get the error

'class' or 'interface' expected

I don't understand why it will not let me use the record keyword.

Any help is appreciated


Solution

  • The records feature arrived in Java 16.

    Project language level is selected to be 15, why didn't you change?