Logical Operators in Java

In Java, logical operators are used to check the logical between variables and values using && (And) , || (or) and !(not) operators.

OperatorDescription of the operator
&& – Logical And Operatorreturns true if the value of both operands .i.e operand1and operand2 is true.
|| – Logical Or Operatorreturn true if the value of either operand .i.e operand1and operand2 is true.
! – Logical Not Operatorreturns true if operand1 is false and returns false if operand1 is true.

You can find the code here

Rutu Shah