public class test {
public static void main(String[] args) {
int count=0;
int p=10;
for(int i=0;i<10;i++)
{
count=count++;
}
System.out.println(count);
}
}
运行结果:0;
分析: 把count++赋值给count,此时count++为0,count为1;赋值后:count又为0。 其实等效为: p=count++; count=p;
<pre name="code" class="java">如果是: count=++count; 或直接: count++; 结果将不为0;