Short-circuit phenomenon: Once the value of the entire expression can be clearly determined, it is not included in the remaining part of the calculation expression.
& Short Circuit exists. Once an expression is used to determine the value of the entire expression, the remaining part does not need to be calculated.
| No short circuit. In any case, all parts of the expression must be calculated.
Package COM. WZS. thread; public class test6 {public static void main (string [] ARGs) {Boolean b1 = test1 (0) & Test2 (3) & test3 (2); system. out. println (); Boolean b2 = test1 (5) | Test2 (1) | test3 (2);} static Boolean test1 (INT value) {system. out. println ("test1:" + value); system. out. println ("Result:" + (value <1); return value <1;} static Boolean Test2 (INT value) {system. out. println ("Test2:" + value); system. out. println ("Result:" + (value <2); return value <1;} static Boolean test3 (INT value) {system. out. println ("test3:" + value); system. out. println ("Result:" + (value <3); return value <1 ;}}
Output result:
Test1: 0 result: truetest2: 3 result: falsetest1: 5 result: falsetest2: 1 Result: truetest3: 2 result: True