Logical Operators Example
Figure 5.19 uses logical operators to produce the truth tables discussed in this section. The output shows the boolean
expression that was evaluated and its result. We used the %b format specifier to display the word “true” or the word “false” based on a boolean
expression’s value. Lines 9–13 produce the truth table for &&
. Lines 16–20 produce the truth table for ||
. Lines 23–27 produce the truth table for &
. Lines 30–35 produce the truth table for |
. Lines 38–43 produce the truth table for ^
. Lines 46–47 produce the truth table for !
.
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.