 Sometimes, you need to test more than one condition at a time. For example, this. A valid score must be greater than or equal to zero and less than or equal to 100. Here's how you write that in Java. The AND is written with two ampersands in a row. For an AND to be true, both conditions must be true. Here's the truth table that shows how AND works. That's a bit abstract, so here's a concrete example. The only combination that works, having both a square and a circle, is when both conditions, having a square and having a circle, are true. Another way to combine conditions is with OR. You want to do something when either one of two conditions is true, as in this example. Here's how we write that in Java, using two vertical bars in a row to mean OR. On US keyboards, the vertical bar is on the key with the backslash. It may be shown as a broken vertical bar, and that's to distinguish it from the capital letter I. Here's the truth table for OR. And here's an example with the squares and circles. The only part that seems weird to people is this last case. If you have both a square and a circle, you still have at least one of them, so this turns out to be true. What if you really do want either A or B but not both, as in this example? Here we don't want to mail an envelope that's too small, but we don't want to mail one that's too big, either. Here's the code for that in Java, using the circumflex for the operation whose official name is exclusive OR. Here is its truth table. The result is true only when the operands are different. And here's the example with the envelope length and width. Just as with arithmetic operators or multiplication and division are more important than addition and subtraction, logical operators also have precedence. That means that this test, as written, is wrong. Without parentheses, this says that the discount is for young people on Saturdays or for anyone on Sunday. To make this work correctly, we need to use parentheses to force the OR to be grouped together and done first. Most people don't have the precedence tables memorized, especially for logical operators. Don't leave this to chance. When in doubt, and even if you aren't in doubt, use parentheses to make your intention clear.