# Demonstrates short-circuiting behavior : Logical Operators « Operators « Java Tutorial

Home
Java Tutorial
 1 Language 2 Data Type 3 Operators 4 Statement Control 5 Class Definition 6 Development 7 Reflection 8 Regular Expressions 9 Collections 10 Thread 11 File 12 Generics 13 I18N 14 Swing 15 Swing Event 16 2D Graphics 17 SWT 18 SWT 2D Graphics 19 Network 20 Database 21 Hibernate 22 JPA 23 JSP 24 JSTL 25 Servlet 26 Web Services SOA 27 EJB3 28 Spring 29 PDF 30 Email 31 J2ME 32 J2EE Application 33 XML 34 Design Pattern 35 Log 36 Security 37 Apache Common 38 Ant 39 JUnit
 Java Tutorial » Operators » Logical Operators
3.7.10.Demonstrates short-circuiting behavior
 ```public class MainClass {   static boolean test1(int val) {     System.out.println("test1(" + val + ")");     System.out.println("result: " + (val < 1));     return val < 1;   }   static boolean test2(int val) {     System.out.println("test2(" + val + ")");     System.out.println("result: " + (val < 2));     return val < 2;   }   static boolean test3(int val) {     System.out.println("test3(" + val + ")");     System.out.println("result: " + (val < 3));     return val < 3;   }   public static void main(String[] args) {     if (test1(0) && test2(2) && test3(2))       System.out.println("expression is true");     else       System.out.println("expression is false");   } }```
```test1(0)
result: true
test2(2)
result: false
expression is false```
 3.7.Logical Operators 3.7.1. Boolean Logical Operators 3.7.2. The following table shows the effect of each logical operation 3.7.3. Logical operators in action 3.7.4. Demonstrate the boolean logical operators 3.7.5. Logical Operators 3.7.6. AND operator 3.7.7. && versus & 3.7.8. Logical OR Operations 3.7.9. Boolean NOT Operations: applies to one boolean operand 3.7.10. Demonstrates short-circuiting behavior