Conditional Operators
Introduction to Conditional Operators

Java includes operators that only use boolean values. These conditional operators help simplify complex boolean relationships by reducing multiple boolean values to a single value.

For example, what if we want to run a code block only if multiple conditions are true. We could use the AND operator: &&.

Or, we want to run a code block if at least one of two conditions are true. We could use the OR operator: ||.

Finally, we can produce the opposite value, where true becomes false and false becomes true, with the NOT operator: !.

We’ll explore each of these operators in this lesson to see how they clean up our conditional statements.


The text editor contains a Reservation class we’ll build in this lesson.

Note the different conditional statements and operators that we’re using to control the execution of the program.

Move on when you’re ready!

Folder Icon

Take this course for free

Already have an account?