- Opening the Source Editor
- Managing Automatic Insertion of Closing Characters
- Displaying Line Numbers
- Generating Code Snippets without Leaving the Keyboard
- Using Code Completion
- Inserting Snippets from Code Templates
- Using Editor Hints to Generate Missing Code
- Matching Other Words in a File
- Generating Methods to Implement and Override
- Generating JavaBeans Component Code
- Creating and Using Macros
- Creating and Customizing File Templates
- Handling Imports
- Displaying Javadoc Documentation While Editing
- Formatting Code
- Text Selection Shortcuts
- Navigating within the Current Java File
- Navigating from the Source Editor
- Searching and Replacing
- Deleting Code Safely
- Changing a Method's Signature
- Encapsulating a Field
- Moving a Class to a Different Package
- Moving Class Members to Other Classes
- Creating a Method from Existing Statements
- Creating an Interface from Existing Methods
- Extracting a Superclass to Consolidate Common Methods
- Changing References to Use a Supertype
- Unnesting Classes
- Tracking Notes to Yourself in Your Code
- Comparing Differences Between Two Files
- Splitting the Source Editor
- Maximizing Space for the Source Editor
- Changing Source Editor Keyboard Shortcuts
Changing a Method's Signature
If you want to change a method's signature, you can use the IDE's Refactor | Change Method Parameters command to update other code in your project that uses that method. Specifically, you can
- Add parameters.
- Change the order of parameters.
- Change the access modifier for the method.
- Remove unused parameters.
You cannot use the Change Method Parameters command to remove a parameter from a method if the parameter is used in your code.
To change a method's signature:
- Right-click the method in the Source Editor or the Projects window and choose Refactor | Change Method Parameters.
- Click Add if you want to add parameters to the method. Then edit the Name, Type, and (optionally) the Default Value cells for the parameter. You have to double-click a cell to make it editable.
- To switch the order of parameters, select a parameter in the Parameters table and click Move Up or Move Down.
- Select the preferred access modifier from the Access Modifier combo box.
-
Click Next.
If you have deselected the Preview All Changes checkbox, the changes are applied immediately.
If you leave the Preview All Changes checkbox selected, the Refactoring window appears with a preview of the changes.
- In the Refactoring window, look at the preview of the code to be changed. If there is a modification that you do not want to be made, deselect the checkbox next to the line for that change.
-
Click Do Refactoring.
If you later find that the refactoring has had some consequences that you would like to reverse, you can choose Refactor | Undo.