boolean

The boolean keyword is used to declare a primitive Java data type containing a truth value. The two possible values of a boolean variable are true and false. Note that true and false are defined as keywords in the Java language, but they are actually literal values. Hence, the keywords true and false can be used as return values, in conditional tests, and in assignments and comparisons to other boolean variables.

The contents of boolean variables cannot be cast to or from other types; the current value of a boolean variable can be converted to a string however.

The following code demonstrates declaration and assignment for a boolean variable:

private boolean isRunning;

isRunning = true;