Jonas
Jonas

Reputation: 159

Rename a variable used in multiple subclasses in Intellij

I have multiple sub classes all overriding a single super class (which is read-only).

Each sub class uses a method like the following:

@Override
public void overridingMethod(int n){
...
}

and I would like to change this to:

@Override
public void overridingMethod(int numberWithABetterName){
...
}

for all classes, without having to refactor it manually for each class. Each class can also be found in the same folder, maybe there's a way to refactor a variable for all classes in a folder?

Upvotes: 1

Views: 402

Answers (1)

Ramanathan Ganesan
Ramanathan Ganesan

Reputation: 582

Click on the Function Name:

  • Choose Shortcut Shift + F6 (or)
  • Right click and select Refactor -> Rename
  • Function name changes to editable text box with rectangle border.
  • Change function name. It will get reflected in all the occurrences including subclasses

Rename the function

Upvotes: 1

Related Questions