- 1 public class HelloWorld {
- 2 public static void main(String[] args) {
- 3
- 4 intx = 3;
- 5 inty = 4;
- 6System.out.println((++x == 3) &( ++ y ==4));// false 与 false 结果为false
- 7System.out.println("x="+x);
- 8System.out.println("y="+y); // y =5
- 9
- 10
- 11System.out.println((++x == 3) && ( ++ y ==4));// false 与 false 结果为false
- 12System.out.println("x="+x);
- 13System.out.println("y="+y);//y = 5 因为短路,y没有参不与运算
- 14
- 15 }
- 16}
来源: