IntelliJ IDEA Tips & Tricks #53: Automatically Extract Superclasses From Existing Classes

Опубликовано: 17 Октябрь 2024
на канале: CodeOpsTech
286
3

You can automatically extract superclasses from existing classes by invoking the "refactor this" menu option by selecting Ctrl + T.

From the Refactor This menu option, choose "Extract Superclass" and choose the fields and methods you want the extracted super class to have. IntelliJ IDEA will automatically make necessary changes to your existing class (for example, introduce super call in the constructor) if you extracted fields to the base class and were initializing those fields in the constructor. So this automated refactoring is better and faster than manually doing this refactoring.