Moving a Class Member to a Superclass

See Also

You can use the Pull Up command to move methods and fields to a class that their current class inherits from.

To initiate the Pull Up operation:

  1. In the Source Editor or Projects window, select the class that contains members that you want to move.
  2. Choose Refactor > Pull Up.

    The Pull Up dialog box appears and displays a list of the class's members and any interfaces that the class implements.

  3. In the Destination Supertype drop-down list, select the class that you want to move the members to.
  4. Select the checkbox for the member or members that you want to move.

    If the current class implements any interfaces, there are checkboxes for these interfaces. If you select a checkbox for an interface, the implements statement for that interface is moved to the superclass.

  5. (Optional) If you want to make a method abstract, select the Make Abstract checkbox for the method. If you select this checkbox, the method will be declared in the superclass as an abstract method and overridden in the current class. The method will be assigned the protected access modifier.
  6. (Optional) If you do not want to review the changes before they are made, clear the Preview All Changes checkbox.
  7. Click Next. If you have cleared the Preview All Changes checkbox, the IDE applies the changes automatically and skips the remaining steps.
  8. The Refactoring window displays the lines of code that will be changed. Review the list and clear the checkbox of any code that you do not want changed.
  9. (Optional) Double-click a file name in the Refactoring window to open the file, or double-click a line of code to open the source file and to position the cursor on that line of code.
  10. Click Do Refactoring to apply the selected changes.
See Also
Refactoring: Quick Reference
Moving an Inner Class One Level Up
Moving a Class Member to a Subclass
Moving a Class to Another Java Package
Extracting a Superclass
Renaming a Class or Interface
Undoing Refactoring Changes

Legal Notices