日常采坑:for中的count++

        int count =0;
        int count1 =0;
        int count2 =0;
        for(int i=0; i<100; i++) {
            count = count++;
            count1 = count1+1;
            count2++;
        }
        System.out.println("count=" + count);
        System.out.println("count1=" + count1);
        System.out.println("count2=" + count2);
    

  结果:

count=0
count1=100
count2=100

   

count = count++ :
  JVM 把 count 值(0)拷贝到临时变量区,然后 count 值加 1,这时 count 的值是 1,
      接着返回临时变量区的值 0,最后返回值赋值给 count,此时 count 值被重置成 0;
原文地址:https://www.cnblogs.com/lcxz/p/12979350.html