已解决问题
谷歌wangyuwei163用户在2013.06.10提交了关于“庐山j**a中对象的属性和行为”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-08-26T08:48:45。publicclassCopyOfTransferProperty{staticinti=47;
publicvoidcall(){
System.out.println("调用call()方法");
for(i=0;i<3;i++){
System.out.print(i+"");
if(i==2){
System.out.println("\n");
}
}
}
publicCopyOfTransferProperty(){
}
publicstaticvoidmain(String[]args){
CopyOfTransferPropertyt1=newCopyOfTransferProperty();
CopyOfTransferPropertyt2=newCopyOfTransferProperty();
CopyOfTransferPropertyt3=newCopyOfTransferProperty();
t2.i=60;
System.out.println("第一个实例对象调用变量i的结果:"+t1.i++);
***.call();
System.out.println("第二个实例对象调用变量i的结果:"+t2.i);
***.call();
}
}
在主方法中定义的t2.i=60;
输出结果t1.i++写成t1.i有什么分别.
为什么输出t2的时候结果不是60而是3.很想不明白.
新手入门请教各位高手.谢谢了.希望大家能够帮助她。
详细问题描述及疑问:publicclassCopyOfTransferProperty{
staticinti=47;
publicvoidcall(){
System.out.println("调用call()方法");
for(i=0;i<3;i++){
System.out.print(i+"");
if(i==2){
System.out.println("\n");
}
}
}
publicCopyOfTransferProperty(){
}
publicstaticvoidmain(String[]args){
CopyOfTransferPropertyt1=newCopyOfTransferProperty();
CopyOfTransferPropertyt2=newCopyOfTransferProperty();
CopyOfTransferPropertyt3=newCopyOfTransferProperty();
t2.i=60;
System.out.println("第一个实例对象调用变量i的结果:"+t1.i++);
***.call();
System.out.println("第二个实例对象调用变量i的结果:"+t2.i);
***.call();
}
}
在主方法中定义的t2.i=60;
输出结果t1.i++写成t1.i有什么分别.
为什么输出t2的时候结果不是60而是3.很想不明白.
新手入门请教各位高手.谢谢了.期待您的答案,你无异于雪中送炭,让我感激涕零
!