Pin It

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 :



Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot