Logical Operators �&�Boolean Expressions
Lesson 6.1
Logical Operators in Java
Using AND
If the sun is shining AND it’s 8am, then let’s go for a walk else let’s stay home.
Using OR
If the sun is shining OR it is 8am, then let’s go for a walk, else let’s stay home.
Using NOT
If NOT the sun is shining, then let’s go for a walk �else let’s stay home.
Truth Tables
Truth Tables
If the sun is shining AND it is 8am, then let’s go for a walk else let’s stay home.
Sun Shining | 8am | Sun Shining & 8am | Action �Taken |
True | True | True | Walk |
True | False | False | Stay Home |
False | True | False | Stay Home |
False | False | False | Stay Home |
Truth Tables
Writing this in Java Code
Java Logical Operators and Precedence
Short-Circuit Evaluation
Short Circuit Evaluation