Work with records
Create a record, or convert between classes and records.
Create record
Create a new record by pressing ⌘N (macOS) / Alt+Insert (Windows/Linux) on the Project tool window. From the New Java Class dialog, type the name of the record and select the Record type.
Convert to record
IntelliJ IDEA can identify classes that are data holders and can be converted to records. The class will be highlighted with a warning. Press ⌥⏎ (macOS) / Alt+Enter (Windows/Linux) and IntelliJ IDEA will suggest converting the class to a record.
The fields will be become record components, the constructor and accessors will be removed. If we had equals, hashCode and toString methods on our class, we can optionally remove these and rely on the default record implementation.
Convert from record
If we decide that maybe a record should be a full Java class, we can get IntelliJ IDEA to automatically convert a record into a Java class.
Press ⌥⏎ (macOS) / Alt+Enter (Windows/Linux) on the record name, and IntelliJ IDEA offers a suggestion to convert the record to a class.