java枚举实现单例模式

421 阅读1分钟

引用一下《Effective Java》的话:

public enum SingletonEnum {
    INSTANCE;
    private int value;

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }
}