Why boolean in Java takes only true or false? Why not 1 or 0 also?

后端 未结 8 1142
太阳男子
太阳男子 2020-12-01 05:28

Is there any reason why Java booleans take only true or false why not 1 or 0 also?

8条回答
  •  生来不讨喜
    2020-12-01 05:42

    Being specific about this keeps you away from the whole TRUE in VB is -1 and in other langauges true is just NON ZERO. Keeping the boolean field as true or false keeps java outside of this argument.

提交回复
热议问题