June 2018
Beginner
722 pages
18h 47m
English
The Boolean type allows a variable to have one of two values: true or false. As we mentioned in the Reserved keywords section, these values are Boolean literals, which means they are values that represent themselves directly – without a variable. We will talk more about literals in the Primitive type literals section.
Here is an example of a b variable declaration and initialization to the value true:
boolean b = true;
And here is another example of assigning a true value to the b Boolean variable using an expression:
int x = 1, y = 1; boolean b = 2 == ( x + y );
In the preceding example, in the first line, two variables, x and y, of the int primitive type are declared and each assigned a value of 1. In the second line, a ...
Read now
Unlock full access