next up previous
Next: Expressions of type boolean Up: Unit 04 Previous: Boolean expressions with variables:

The primitive data type boolean

Type boolean
Dimension 1 bit
Domain the two truth values true and false
Operations && and Note: in a && b, the value of b is computed only if a is true
  || or Note: in a || b, the value of b is computed only if a is false
  ! not
Literals true and false

Example:

boolean a,b,c,d,e;
a = true;
b = false;
c = a && b;              // c = a and b
d = a || b;              // d = a or b
e = !a;                  // e = not a
System.out.println(e);   // prints a string representing a boolean value,
                         // in this case the string "false" is printed


next up previous
Next: Expressions of type boolean Up: Unit 04 Previous: Boolean expressions with variables: