CODEARTS IDE-移动内部类到上层:重构后

时间:2024-04-16 15:05:23

重构后

class OuterClass {
    String str = "test";
    public void outermethod(){
        InnerClass ic = new InnerClass(this);
        ic.print();
    }
}

class InnerClass {
    private final OuterClass outerClass;

    public InnerClass(OuterClass outerClass) {
        this.outerClass = outerClass;
    }

    public void print() {
        System.out.println(outerClass.str);
    }
}
support.huaweicloud.com/usermanual-codeartside/codeartside_01_0120.html