In this tutorial, we will learn Java Conditional Operators. Conditional operators are also called as logical operators. These operators operate on boolean expressions.
|&&||booleanExp1 && booleanExp2|
|Logical OR||||||booleanExp1 || booleanExp2|
The logical AND operator evaluates to true if both the boolean expressions are true, otherwise evaluates to false.
The logical OR operator evaluates to false if both the boolean expressions are false, otherwise evaluates to true.
The ternary operator uses three operands. It evaluates a boolean expression and if the boolean expression is true, the second operand is returned , otherwise, it returns the third operand.
output = booleanExp ? value1 : value2 ;
If the booleanExp evaluates to true the value1 is assigned to output variable. If the booleanExp evaluates to false the value2 is assigned to output variable.
Java Tutorial on this website:
For more information on Java, visit the official website :