Created
May 29, 2021 10:11
-
-
Save MrRahulR/3606f6a6f36c99150fc09ea9f3de3230 to your computer and use it in GitHub Desktop.
LogicalOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.qacaffe; | |
public class LogicalOperator { | |
public static void main(String[] args) { | |
//Variable Declaration | |
int a = 1; | |
int b = 2; | |
//Logical Operators | |
System.out.println("a is 1 AND b is 2, therefore it is " + ((a == 1) && (b == 1))); | |
//false because value of b is 2 not 1 | |
System.out.println("a is 1 OR b is 1 therefore it is " + ((a == 1) || (b == 1))); | |
//true because one value is true | |
System.out.println("a is not equal to b is " + (a != b)); | |
//true because a is not equal to b | |
} | |
} | |
/* | |
Output : | |
a is 1 AND b is 2, therefore it is false | |
a is 1 OR b is 1 therefore it is true | |
a is not equal to b is true | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment