打印过程中依然会让变量重新赋值,所以合理的分析代码运行过程很重要
public class operation
{
public static void main(String[] args)
{
int x = 20;
int y = 12;
boolean m = 100==(x + y);
boolean z = false;
System.out.println(m ); //false
System.out.println(x == y + 10); //false
System.out.println(z||m); //false
System.out.println(x *= 19); //x = x*19
System.out.println(y/2 >=x ? 3:6); //6 分析12/2=6 6>=20 false 所以3:6 执行6。
System.out.println(x%y); //8
System.out.println(y >=6 && y <=x); //true
System.out.println(!((x*3) <= x*4)); //false
int xx = 10;
int yy = 5;
System.out.println(xx++ * yy++); // 50 xx*yy 后在将xx自增1,yy自增1.
System.out.println(xx); // 11
System.out.println(yy); // 6
System.out.println(++xx * yy--); // 72 先将xx自增1,在让xx*yy,然后在让yy自减1.
System.out.println(xx); // 12
System.out.println(yy); // 5
System.out.println(xx++*2/++yy); // 4 xx*2/(yy+1).再让xx自增1
System.out.println(xx); //13
System.out.println(yy); //6
System.out.println(xx++ - ++yy); //6
System.out.println(xx); //14
System.out.println(yy); //7
}
}
public class operation
{
public static void main(String[] args)
{
int x = 20;
int y = 12;
boolean m = 100==(x + y);
boolean z = false;
System.out.println(m ); //false
System.out.println(x == y + 10); //false
System.out.println(z||m); //false
System.out.println(x *= 19); //x = x*19
System.out.println(y/2 >=x ? 3:6); //6 分析12/2=6 6>=20 false 所以3:6 执行6。
System.out.println(x%y); //8
System.out.println(y >=6 && y <=x); //true
System.out.println(!((x*3) <= x*4)); //false
int xx = 10;
int yy = 5;
System.out.println(xx++ * yy++); // 50 xx*yy 后在将xx自增1,yy自增1.
System.out.println(xx); // 11
System.out.println(yy); // 6
System.out.println(++xx * yy--); // 72 先将xx自增1,在让xx*yy,然后在让yy自减1.
System.out.println(xx); // 12
System.out.println(yy); // 5
System.out.println(xx++*2/++yy); // 4 xx*2/(yy+1).再让xx自增1
System.out.println(xx); //13
System.out.println(yy); //6
System.out.println(xx++ - ++yy); //6
System.out.println(xx); //14
System.out.println(yy); //7
}
}