## 1.布尔逻辑

``(18 < age) AND (age < 65)``

Java 中存在三种逻辑运算符：`AND`(&&)、`OR`(||) 和`NOT`(!)。

`AND` (∧) `and` `&&`
`OR` (∨) `or` `||`
`NOT` (¬) `not` `!`

``(0 < a) && (a < 100)``
``(0 < a) and (a < 100)``
``(0 < a) and (a < 100)``
``(!a) && (!b)``
``(not a) and (not b)``
``(NOT a) AND (NOT b)``
``!(!a || !b)``
``not((not a) or (not b))``
``NOT((NOT a) OR (NOT b))``

## 2.使用比较运算符和布尔变量的例子

``````int age = 35;
if (age >= 18 && age <= 65)
System.out.println("You can work");``````

``````int age = 35;
boolean isYoung = (age < 18);
if (!isYoung && age <= 65)
System.out.println("You can work");``````

``````int age = 35;
boolean isYoung = (age < 18);
boolean isOld = (age > 65);
if (!isYoung && !isOld)
System.out.println("You can work");``````

## 3.逻辑运算

``true && true``
``true``
``true && false``
``false``
``false && true``
``false``
``false && false``
``false``

``true || true``
``true``
``true || false``
``true``
``false || true``
``true``
``false || false``
``false``

``!true``
``false``
``!false``
``true``

``m && !m``
``false``
``m || !m``
``true``
``!(a && b)``
``!a || !b``
``!(a || b)``
``!a && !b``