JMU
Logical Operators
An Introduction with Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu


Review
Going Further: Operator Notations
Going Further: Operator Notations (cont.)
Logical Operators
Truth Tables
images/truth_tables.gif
The boolean Type in Java
Logical Operators in Java
boolean Variables in Java

Example

// Declare a boolean variable named ok
boolean   ok;

// Assign the value true to ok
ok = true;
Examples of Expressions Involving Logical Operators in Java
Short-Circuiting
Short-Circuiting (cont.)
Gaining Experience with Short Circuiting
Short-Circuiting (cont.)