Moving an Inner Class One Level Up

See Also

You can use the Move Inner to Outer Level command to do move an inner class one level up in hierarchy.

For example, if the selected class is directly nested in a top-level class, a new top-level class is created. If the selected class is nested in an inner class, the selected class is moved to the level of the inner class that it was nested in.

To use the Move Inner to Outer Level operation:

  1. In the Source Editor, place the insertion point in the inner class that you want to convert.
  2. Choose Refactor > Move Inner to Outer Level.

    The Move Inner to Outer Level dialog box appears.

  3. In the Class Name field, change the name of the class, if necessary.
  4. (Optional) Select the Declare Field for the Current Outer Class field if you want to generate an instance field for the current outer class and pass the outer class to the constructor. If you select this checkbox, type a name for the the outer class' instance field.
  5. If you click Refactor, the IDE applies the changes automatically and skips the remaining steps. If you click Preview, 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. If the class that you are pushing members from has multiple subclasses and you do not want the members to be pushed to all of them, be sure to clear the checkboxes for the corresponding subclasses. Click Do Refactoring to apply the selected changes.
See Also
Refactoring: Quick Reference
Moving a Class Member to a Superclass
Moving a Class Member to a Subclass
Converting an Anonymous Inner Class to a Regular Inner Class
Moving a Class to Another Java Package
Renaming a Class or Interface
Undoing Refactoring Changes

Legal Notices