📜  java代码示例中的静态setter和getter示例是什么

📅  最后修改于: 2022-03-11 14:52:28.561000             🧑  作者: Mango

代码示例1
class SomeClass {
    private static Data data;

    public static void setData(String data) {
        data = new Data(data);
    }

    public static String getData() {
        return data.toString();
    }
}

class Data {
    private String data;

    public Data(String data) {
        this.data = data;
    }

    public String toString() {
        return data;
    }
}