int x=1,y=1,z=1; if (x--==1&&y++==1||z++==1) System.out.println("x="+x+",y="+y+",z="+z); } }上面是public class test {public static void main(String args[]) {新手就、求详解

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 10:43:25

int x=1,y=1,z=1; if (x--==1&&y++==1||z++==1) System.out.println("x="+x+",y="+y+",z="+z); } }上面是public class test {public static void main(String args[]) {新手就、求详解
int x=1,y=1,z=1; if (x--==1&&y++==1||z++==1) System.out.println("x="+x+",y="+y+",z="+z); } }
上面是public class test {
public static void main(String args[]) {
新手就、求详解

int x=1,y=1,z=1; if (x--==1&&y++==1||z++==1) System.out.println("x="+x+",y="+y+",z="+z); } }上面是public class test {public static void main(String args[]) {新手就、求详解
x=0,y=2,z=1
(x--==1&&y++==1||z++==1) 相当于((x--==1&&y++==1)||z++==1) )
x--==1 为true 执行后 x=0
双与 && 是前面的条件如果为true,后面的条件也要判断一次,所以y++==1也执行了
y++==1 为true 执行后 y=2
两个都为true,那么(x--==1&&y++==1)为true,
而双或 || 是前面的条件如果为true,后面的条件就不再判断,结果肯定是true.
所以z++==1并没有执行,z的值不变.