如何安全地更改变量intellij的类型? [英] How to safe change the type of a variable intellij?

查看:615
本文介绍了如何安全地更改变量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

这篇关于如何安全地更改变量intellij的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆