public static void main(String[] args) { int res1 = 0; int res2 = 0; int c = 0; for (int i = 0; i < 10; i++) { //++单目运算符优先级高于+=赋值运算符优先级 //res1+=res1++等价于 (res1=res1++;res1是先使用后自增,则res1=0,然后res1=res1+res1,结果res1仍是0) res1 += res1++; c++; } for (int i = 0; i < 10; i++) { //res2先使用赋值给res2则res2值为0,然后res2再自增,但是却没有赋值给任何一个变量 res2 = res2++; res2 = res2 + res2; } System.out.println("res1=" + res1); System.out.println("res2=" + res2); System.out.println(c); }