Logical Operators in Detail



This video tutorial explains the not, and, or,exclusive or logical operators available in java programming.

You will learn what are the logical operators available in java, how to use not ( ! ) operator, how to use and ( && ) operator, how to use or ( || ) operator, how to use exclusive or ( ^ ) operator in detail with examples.

Source code for this video tutorial


package learningJava;

public class Orange {
 public static void main(String[] args) {
  
  boolean human = false;
  if(!human){
   System.out.println("Am a human");
  }else{
   System.out.println("Am not a human");
  }
  
  
  int number = 6;
  
  if( (number % 2 == 0) && (number % 3 == 0) ){
   System.out.println(number+" is completely divisible by both 2 and 3");
  }else{
   System.out.println(number+" is not completely divisible by both 2 and 3");
  }
  
  if( (number % 2 == 0) || (number % 3 == 0) ){
   System.out.println(number+" is completely divisible by  2 or 3");
  }else{
   System.out.println(number+" is not completely divisible by both 2 or 3");
  }
  
  if( (number % 2 == 0) ^ (number % 3 == 0) ){
   System.out.println(number+" is completely divisible by  2 or 3 but not the both");
  }

 }

}



Back To Top