If you've ever tried to alter a variable's name manually, you'll know that it's a tedious process. In order for the program to compile, all occurrences of the variable must be found and changed to the new name. However, Eclipse makes this task extremely easy by providing a re-factoring tool that automatically finds and updates variable names. The build used here is Eclipse Ganymede 3.4.0.

Steps

  1. 1
    Highlight and right click on the variable you want to rename. Navigate to Refactor and select Rename....
  2. 2
    Type in your new variable name and press Enter.
    Advertisement
  3. 3
    Verify that occurrences of the variable are updating as you type.
  4. 4
    Check through the source code to ensure that no errors have arisen.
  5. Advertisement

Warnings

  • If there are any syntax errors near occurrences of your variable, those occurrences may not re-factor correctly since Eclipse will not know how to handle the errors. Always check problematic areas after refactoring.
    ⧼thumbs_response⧽
Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 9 people, some anonymous, worked to edit and improve it over time. This article has been viewed 138,375 times.
How helpful is this?
Co-authors: 9
Updated: June 3, 2021
Views: 138,375
Categories: Java
Advertisement