Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor
Conditionals and Control Flow

Boolean Operators: ||

Great! The second Boolean operator that we will explore is called or.

  1. The or operator is represented in Java by ||.
  2. It returns a Boolean value of true when at least one expression on either side of || is true.

The code below shows all the outcomes of the Boolean operator ||:

//The "or" Boolean operator: System.out.println(false || false); // prints false System.out.println(false || true); // prints true System.out.println(true || false); // prints true System.out.println(true || true); // prints true

We can also use the Boolean operator || with Boolean expressions such as the following:

System.out.println(2 > 1 || 3 > 4);

The example above will print out true because at least one statement — "2 is greater than 1" — is true even though the other statement — "3 is greater than 4" — is false.

Report a Bug
If you see a bug or any other issue with this page, please report it here.