Chapter Table of Contents

Ch. 6 Conditionals

Section Table of Contents

Logical operators are binary operators that allow you to combine different boolean expressions (a boolean expression is basically something that can evaluate to either true or false). Look at the tables below to learn about them. The tables are divided into 2 sections: a truth table, and examples. For the truth table section, p refers to any boolean expression.

<aside> 💡 For a deeper explanation, you can also watch this Crash Course video (note: don’t worry too much about the logic gates and transistors — focus on what AND, OR, XOR, and NOT mean conceptually).

</aside>

Logical Operators

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e008e595-1a97-404b-bdd3-0a06e19fe407/Untitled.png

Credit: Y. Daniel Liang, Introduction to Java Programming (Comprehensive Version), 10th ed.

<aside> ⚠️ NOTE: There is an error in the first example. It should say that the overall expression is false because (age > 28) is false.

</aside>

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/f454c96a-fa69-47aa-b867-5060cc17500e/Untitled.png

Credit: Y. Daniel Liang, Introduction to Java Programming (Comprehensive Version), 10th ed.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/3253889b-19ef-4086-880f-1915378bb038/Untitled.png

Credit: Y. Daniel Liang, Introduction to Java Programming (Comprehensive Version), 10th ed.