为什么布尔在Java中只需真的还是假的?为什么不1或0也?

问题描述:

是否有任何理由为什么Java的布尔只需要真正为什么不 1 0 也?

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

Java的,不像在C和C语言++,对待布尔作为了2个完全独立的数据类型不同的值:true和false。值1和0是int类型,而不是隐式转换为布尔

Java, unlike languages like C and C++, treats boolean as a completely separate data type which has 2 distinct values: true and false. The values 1 and 0 are of type int and are not implicitly convertible to boolean.