(四)下面程序是否有问题?如果存在请说出问题所在,如果不存在,说明输出结果。
public class Test{
public static void main(String args[]){
Test t = new Test();
int i = 0;
t.increase(i);
i = i++;
System.out.println(i);
}
void increase(int i){
i++;
}
}
答案:不存在问题,输出结果为0.
解析:i=i++原理:
1)tem = i;
2) i = i+1;
3) i = tem;结果i变为0;