CODEARTS IDE-封装字段:重构后

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

重构后

class Person {
    private String name;

    public static void main(String[] args) {
        Person person = new Person();
        person.setName("John");
        System.out.println(person.getName());
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
support.huaweicloud.com/usermanual-codeartside/codeartside_01_0151.html