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
.