Immutable模式想破坏也破坏不了。

Immutable模式想破坏也破坏不了。_第1张图片

public final class Person {
    private final String name;
    private final String address;
    public Person(String name,String address){
        this.name = name;
        this.address = address;
    }
    public String getName(){
        return name;
    }
    public String getAddress(){
        return address;
    }
    public String toString(){
        return "[ Person:name =" + name +", address =" +address +" ]";
    }
}

Immutable模式想破坏也破坏不了。_第2张图片

你可能感兴趣的:(java,开发语言)