public class BankAccount {
private int balance;
public void setBalance(int x) {
balance = x;
}
public int getBalance() {
return balance;
}
}
Here the field balance
is defined as an integer and the methods which are involved with that field are also implemented according to that type. For some reason, if I change private int balance
to private double balance
, then I will have to change the return types and parameter types of the methods involved with that field. I can do this manually but for larger codes, that will become tedious. Is there any way to get Intellij to do that for me?
Place the caret on the type (in your case int) Right Click -> Refactor -> Type Migration
and type the type you want to migrate and click refactor.
Shortcuts: