IntelliJ IDEA
 
Get IntelliJ IDEA

Extract interface

Last modified: 11 October 2024

With the Extract Interface refactoring you have the following options:

  • Create an interface based on the methods of a class.

  • Rename the original class, and it implements the newly created interface. In such case, IntelliJ IDEA changes all usages of the original class to use the interface where possible.

In addition, static final fields, declared in the initial class, can be moved to an interface. As a result,an interface will be created containing the specific methods and fields. Thereby, the specified class methods become implementations of the corresponding interface methods.