Java Reference
In-Depth Information
Moving static methods and fields to other classes
The Move command has another nifty trick up its sleeve. When you call it from
within the editor, the command moves static members out of the class and into
another class.
If you type in the name of a class that doesn't yet exist, IDEA will offer to
create it for you.
TIP
When you execute the command, you're presented with a dialog like the one
shown in figure 9.16. In the To field, enter the fully qualified name of the class
that will receive the methods or static fields. You can use the class browser to select
the destination class by clicking the browse button ( ) next to the field. Then,
select the methods or fields to move from the list of appropriate selections from
the current class. You can use the Visibility options to modify the visibility of the
members in their new location. The default value, As is , preserves the current
visibility of each moved item.
The Move refactoring for methods can now be used to move a method from one
class to another even if the method isn't declared static. Previously, only static
methods could be relocated like this. Note that you can't move constructors and
methods that are part of the class hierarchy.
Figure 9.16
The Move refactoring does
more than move files
around; it also lets you
move static methods and
fields between classes.
 
 
Search WWH ::




Custom Search