Mutable boolean field in Java

前端 未结 9 2268
挽巷
挽巷 2020-12-09 07:32

I need a mutable boolean field in Java (I will return this field via get* method later and it should be possible to modify this field).

Boolean doesn\'t work because

9条回答
  •  感动是毒
    2020-12-09 07:59

    What about just using the boolean primitive?

    private boolean value;
    
    public void setValue(boolean value) {
        this.value = value;
    }
    
    public boolean getValue() {
        return value;
    }
    

提交回复
热议问题