boolean
type
The boolean
type represents logical values of true
or false
. Combine boolean
expressions with logical operators &&
(and), ||
(or), and !
(not).
Example:
boolean test1 = 7 < 10; // true boolean test2 = (1 == 2); // false if ((test1 || test2) && 2 + 2 != 5) { System.out.print("hello"); // output: hello }