标题:变量输出问题
取消只看楼主
zt815082858
Rank: 1
等 级:新手上路
帖 子:56
专家分:3
注 册:2016-10-30
结帖率:61.54%
 问题点数:0 回复次数:0 
变量输出问题
public class TransferProperty {                        
    int i=47;                                                
    public void call() {                        
        System.out.println("调用call()方法");
        for(i=0;i<3;i++) {
            System.out.print(i+" ");————————————————》1、为什么这里以i和+i都可以输出呢?
            if(i==2) {
                System.out.println("\n");
            }
        }
    }
public TransferProperty() {//构造方法
}
public static void main(String args[]) {//主方法
    TransferProperty t1=new TransferProperty();
    TransferProperty t2=new TransferProperty();
    t2.i=60;
    System.out.println("第一个实例对象调用变量i的结果:"+t1.i++);——————————>这里的++有什么作用?
    t1.call();
    System.out.println("第二个实例对象调用变量i的结果:"+t2.i);
    t2.call();
}

}

第一个实例对象调用变量i的结果:47
调用call()方法
0 1 2

第二个实例对象调用变量i的结果:60
调用call()方法
0 1 2

搜索更多相关主题的帖子: 变量 call System out 调用 
2017-11-11 09:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-482351-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.573235 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved