0


Logical Operators – Logical operators are used to connect more relational operations to form a complex expression called logical expression. A value obtained by evaluating a logical expression is always logical, i.e. either true or false.
Operator
Meaning
Example
Result
&&
Logical AND
(5<2)&&(5>3)
False
||
Logical OR
(5<2)||(5>3)
True
!
Logical NOT
!(5<2)
True

&&
Operand 1
Operand 2
Result
True
True
True
True
False
False
False
True
False
False
False
False

||
Operand 1
Operand 2
Result
True
True
True
True
False
True
False
True
True
False
False
False

!
Operand
Result
False
True
True
False


Example : -

class Geekyshows
{
    public static void main (String args[])
    {
        int a = 10, x = 20;
        int b = 20, y = 30;
        boolean c  = (a<x) && (b<y);
        System.out.println("Result: "+c);
    }
}

Post a Comment

Comment Rules :
1. Do not post Adult/illegal Links.
2. Try to comment in only English Language.
3. Do not post other website's links which are useless.
4. Your Comment should be based on the Topic for other queries Kindly Visit our Contact Us Page.
5. Do not use Abusive Language.
6. Respect each other.
Thank You for following the rules. Please Comment....

 
Top