One thing to keep in mind is the second condition is not evaluated if the first one is false, i.e. it has a short-circuiting effect. Used extensively to test for several conditions for making a decision.
Condition1 || Condition2 // returns true if one of the conditions is true.
Below is an example to demonstrate || operator:
a is an alphabet.
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Ternary operator vs Null coalescing operator in PHP
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- Java Ternary Operator Puzzle
- Difference between concat() and + operator in Java
- && operator in Java with Examples
- & Operator in Java with Examples
- Equality (==) operator in Java with Examples
- Java Unary Operator with Examples
- Java Ternary Operator with Examples
- Java Assignment Operator with Examples
- unordered_multiset operator = in C++ STL
- unordered_set operator= in C++ STL
- 'AND' vs '&&' as operator in PHP
- What is the difference between the | and || or operator in php?
- set operator= in C++ STL
- unordered_set operator!= in C++ STL
- unordered_set == operator in C++ STL
- Double not (!!) operator in PHP
- Operator Overloading in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.