publicclassCopyOfTransferProperty{staticinti=47;publicvoidcall(){System.out.println("调用call()方法");for(i=0;i<3;i++){System.out.print(i+"");if(i==2){System.out.println(...
public class CopyOfTransferProperty {
static int i=47;
public void call(){
System.out.println("调用call()方法");
for(i=0;i<3;i++){
System.out.print(i+" ");
if(i==2){
System.out.println("\n");
}
}
}
public CopyOfTransferProperty(){
}
public static void main(String[] args) {
CopyOfTransferProperty t1=new CopyOfTransferProperty();
CopyOfTransferProperty t2=new CopyOfTransferProperty();
CopyOfTransferProperty t3=new CopyOfTransferProperty();
t2.i=60;
System.out.println("第一个实例对象调用变量i的结果:"+t1.i++);
t1.call();
System.out.println("第二个实例对象调用变量i的结果:"+t2.i);
t2.call();
}
}
在主方法中定义的t2.i=60;
输出结果t1.i++写成t1.i有什么分别.
为什么输出t2的时候结果不是60而是3.很想不明白.
新手入门请教各位高手.谢谢了.
那如果方法中我把i++.改成i
输出结果是一样。。那写成i有什么分别。我知道i++是运算后递增1.
t2的值等于3很想不明白。怎么循环到3了。。
2~3楼得解释得我不太明白。
有没有说详细的。 谢谢了。
展开