Logical Operators Examples in Java


Here is the simple program for printing logical operators in Java.

Source Code

/* 
  Tutor Joes Computer Education  
  www.tutorjoes.com
*/ 
import java.io.*;
import java.util.Scanner;
class logic
{
  public static void main(String args[])
  {
  /*
    Logical Operator
  	&& And
  	00  0
  	01  0
  	10  0 
  	11  1
  	|| Or
  	00  0
  	01  1
  	10  1
  	11  1
  	! Not
  */
   int a=20,b=100;
   System.out.println("And : "+((a>=b)&&(a==b)));
   System.out.println("Or : "+((a>b)||(a==b)));
   System.out.println("Not : "+(a!=b));
  }
}
To download raw file Click Here

Output

And : false
Or : false
Not : true



Learn All in Tamil © Designed & Developed By Tutor Joes