如何安全地更改变量intellij的类型?

问题描述:

假设我有一个像这样的课程.

Suppose I have a class like this.

Public class MyClass{
    private String id;

    public Myclass(String id){
        this.id = id;
    }

    public String getId(){
        return id;
    }

    public void setId(String id){
        this.id = id;
    }
}

突然我想将type of id更改为Integer.有没有办法使用 intellij 来做到这一点而又不会破坏用法?

And suddenly I want to change the type of id into Integer. Is there a way to do that with intellij without breaking usages?

突出显示字段类型,然后按 Ctrl + Shift + F6

Highlight the type of field and press Ctrl+Shift+F6

突出显示字段类型,Right-Click -> Refactor -> Type migration

突出显示字段类型,Menu -> Refactor -> Type migration