按位运算操作符(& ,| )两边的都要计算逻辑运算如果操作符(&&, || )左边成立则就不在计算右边了
实例:
[java] view plaincopyprint?
- public class test {
- private static int j = 0;
-
- private static boolean methodB(int k) {
- j += k;
- return true;
- }
-
- public static void methodA(int i) {
- boolean b;
- b = i < 10 | methodB(4);
- b = i < 10 || methodB(8);
- }
-
- public static void main(String args[]) {
- methodA(0);
- System.out.println(j);
- }
- }
|
|