05.0 Java Notes‎ > ‎

Java: Boolean Expressions and Logical Operators

Comparison Operators

  • compares two values and will evaluate to either true or false

Comparison Java Symbol 
 less than
 greater than
 equal to== 
 not equal to!= 
 less than or equal to<= 
 greater than or equal to>= 

Logical Operators

Logical operators are operators that operate on Boolean values -- that is values that are true of false.

 Logical OperatorJava symbols Truth Table 
 And &&
ANDT
TT
F
 Or ||
OR
TT
F
 Not !
  NOT
 T
 F

Boolean Expressions

  • boolean is a primitive java data type
  • a Boolean expression is an expression that evaluates to either true of false
  • true and false are both reserved words in java 
  • Boolean expressions are made up of comparison and logical operators
  • boolean expressions can be used in the if statements and conditional loops
  • boolean expressions can also be used is assignment statements
Sample Boolean expressions:
  • age > 16
  • myAge != yourAge
  • ((age >16) && (sex == "F"))
  • !isWorking



Comments