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
.
Get Java For Dummies Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.