【问题标题】:How to safe change the type of a variable intellij?如何安全地更改变量 intellij 的类型?
【发布时间】:2016-07-18 03:24:51
【问题描述】:

假设我有这样的课程。

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 做到这一点?

【问题讨论】:

  • 可以提供safe change的详细信息吗?我不知道你的期望是什么
  • 我想通过一次操作将变量'id'的类型从String更改为Integer,而不是一一改变用法。

标签: java variables intellij-idea types intellij-14


【解决方案1】:

突出显示字段类型并按Ctrl+Shift+F6

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多