Boolean expressions in Java

后端 未结 8 1181
不知归路
不知归路 2020-12-21 06:00

I have a question about the meaning (evaluation) of Boolean variables in return statements in Java.

I know that:

if (var) { ... }

i

8条回答
  •  温柔的废话
    2020-12-21 06:40

    It's not an "implicit assumption," it's what the compiler's doing. The b < a is just an expression, the same as if it were used for an if statement. The expression evaluates to a boolean, which is then returned.

    Also noteworthy, you seem to interchange boolean and Boolean as though they're the same, but they're actually not. boolean is the primitive form while Boolean is an Object that wraps a boolean.

提交回复
热议问题