Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Does false in Java mean 1 or 0?

Shulou Source: shulou.com Published: 2022-06-02 14:11:39 10月10日 Update

Editor to share with you whether false refers to 1 or 0 in Java. I hope you will get something after reading this article. Let's discuss it together.

False is 0 false is a value of Boolean type, the value of Boolean variable is only false and true,0 is false, non-0 is true; Boolean variable can be used for logical expressions, that is, logical operations such as "or" and "not" and relational operations such as greater than less than.

False is 0. False is a Boolean value. Only false and true,0 are false for Boolean variables, and non-zero is true. (for example,-1 and 1 are both true).

Boolean variables can be used for logical expressions, that is, logical operations such as "or" and "not" and relational operations such as greater than less than, and the result of logical expression operation is true or false.

Boolean results are often used in conditional statements. Here is an example of Java syntax:

Bool (a & b) {System.out.println ("1"); / / only if an and b are true (that is, non-zero values), execute here} else if (b) {System.out.println ("2"); / / only if b is true (that is, non-zero values), execute here} else {System.out.println ("3"); / / execute here} if none of the previous conditions are met

So the output is: 3

After reading this article, I believe you have a certain understanding of "false refers to 1 or 0 in Java". If you want to know more about it, welcome to follow the industry information channel. Thank you for your reading!

Tags: Boolean operations logic variables only results expressions or that is conditions articles types over more knowledge industry statements grammar information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Linux Shulou Technology Huawei Apple