Boolean-valued Expressions

Contact Us or call 1-877-932-8228
Boolean-valued Expressions

Boolean-valued Expressions

Java has a data type called boolean. Note the following:

  • Possible values are true or false.
  • boolean can be operated on with logical or bitwise operators, but cannot be treated as a 0 or 1 mathematically.
  • boolean can be specified as a parameter type or return value for a method.
  • A boolean value will print as true or false.

The result of a conditional expression (such as a comparison operation) is a boolean value. Note that:

  • Simple comparisons, such as greater than, equal to, etc., are allowed.
  • Values are returned from functions.
  • Complex combinations of simpler conditions are allowed.

Conditional expressions are used for program control. That means they provide the ability for a program to branch based on the runtime condition or iterate through a block of code until the condition is false.