Comp 110 boolean

boolean

What is a boolean?

  • A boolean is a built-in simple data type
  • A boolean can ONLY be EITHER true or false
  • Watch out! booleans have their own operators, check those out here: Boolean Operators

boolean Literals

The words true and false are special keywords in Java and are boolean literals.

true
false

Declaration and Assignment

You can declare and assign boolean variables as follows:

boolean isProgrammingFun = true;
boolean isCOMP110AnEasyA = false;

Control Flow Statements and booleans

Control flow statements (conditionals and loops) depend on boolean values. Being comfortable with the idea of a boolean, boolean variables, and its logical operators will improve your ability to make effective use of control flow statements tremendously.