Skip to content

Instantly share code, notes, and snippets.

@MrRahulR
Created May 29, 2021 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrRahulR/3606f6a6f36c99150fc09ea9f3de3230 to your computer and use it in GitHub Desktop.
Save MrRahulR/3606f6a6f36c99150fc09ea9f3de3230 to your computer and use it in GitHub Desktop.
LogicalOperator.java
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