Primitive TypesTopBooleans - true and falseBooleans - true and false

Booleans - true and false

The boolean data type represents the values true and false. Variables of type boolean are very useful for remembering whether something succeeded or not.

If we declare a variable

   boolean carryingBall;

then we can revise the onMousePress and onMouseRelease methods to use that boolean variable. Click on EvenBetterBasketball for an improved version of the program using the boolean variable.

boolean is a primitive type. Recall that primitive types differ from object types because:


Primitive TypesTopBooleans - true and falseBooleans - true and false