Implement methods of an interface or abstract class
If a class is declared as implementing a certain interface or extending a class with abstract methods, it has to implement the methods of such interface or class. IntelliJ IDEA creates stubs for implemented methods, with the default return values for the primitive types, and null values for the objects.
Implement required methods
From the main menu, select Generate Alt+Insert, and select Implement methods.
or press Ctrl+I. You can also right-click anywhere in the class file, then clickIn the dialog that opens, select the methods to implement. If necessary, select the Copy JavaDoc checkbox to insert JavaDoc comments for the implemented methods.
Click OK.
Change method body
The code template used for implementing methods (Implemented method body) accepts predefined template variables from the File Header include template (such as ${USER}
, ${DATE}
, and so on)
For example, consider the following file template:
Provided that the implemented interface contains two methods, this template expands into the following code: