Free Data Structures and Algorithms Course









Subscribe below and get all best seller courses for free !!!










OR



Subscribe to all free courses

Short Circuiting in Java Programming Language

Program to demonstrate Short Circuiting in Java

public class ShortCircuiting {
   
  public static boolean one(int i){
  
     System.out.println("Evaluated : one");
     return i < 2;
  
  }
 
  public static boolean two(int i){
  
     System.out.println("Evaluated : two");
     return i < 2;
  
  }
 
  public static boolean three(int i){
  
    System.out.println("Evaluated : three");
    return i < 4;
  
  }
 
  public static void main(String[] args) {
  
    boolean b = ( one(1) && two(2) && three(3) );
  
    System.out.println("Evaluation result :" + b);

  }

}


Output of the program :



 
© 2021 Learn Java by Examples Template by Hubberspot