boolean Data Type

A boolean type can have one of two values: true or false. A boolean is used to perform logical operations, most commonly to determine whether some condition is true. For example:

boolean enrolled = true;

boolean credited = false;

Here, a variable named enrolled of type boolean is declared and initialized to a value of true, and another boolean named credited is declared and initialized to false.

Warning.eps In some languages, such as C or C++, integer values can be treated as a boolean, with 0 equal to false and any other value equal to true. Not so in Java. In Java, you can’t convert between an integer type and a boolean type.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset