Convert compact source file to class

Convert a compact source file to a class in IntelliJ IDEA.

Java 25 introduced the concept of implicit classes or compact source files. We can convert an implicit class to a regular class as needed. Invoke Context Actions by pressing ⌥⏎ (macOS) / Alt+Enter (Windows/Linux) and select Convert an implicitly declared class of a compact source file into a regular class.

The reverse is also possible, should you prefer to use an implicit class at any point. To do so, use the quick-fix Convert into compact source file.

Interested in JVM Development?

call to action image

You can create a compact source file in IntelliJ IDEA.

Learn More

Related Resources

Add static import for simple IO
Add static import for simple IO
Add a static import for simple IO methods.
Use Pattern Matching for instanceof
Use Pattern Matching for instanceof
Inspections can guide us to use newer Java features.
Work with records
Work with records
Create a record, or convert between classes and records.