Changing a Method s Signature


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:

  1. Right-click the method in the Source Editor or the Projects window and choose Refactor | Change Method Parameters.

  2. 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.

  3. To switch the order of parameters, select a parameter in the Parameters table and click Move Up or Move Down.

  4. Select the preferred access modifier from the Access Modifier combo box.

  5. 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.

  6. 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.

  7. 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.



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net