标题:关于this的问题~哪位高手告诉我下啊~!!!
取消只看楼主
zaneljp
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-6-29
 问题点数:0 回复次数:1 
关于this的问题~哪位高手告诉我下啊~!!!
public class Leaf{
    int i = 0;
  //int increment() {
  Leaf increment() {
        i++;
    //return i;
      return this;
        }
    void print() {
        System.out.println("i = " + i);
        }
    public static void main(String[] args){
        Leaf x = new Leaf();
        x.increment().increment().increment().print();
  }
}
有哪位高手能帮忙告诉我下这段代码里面的this里的用处啊~
this我听说过,但是到底是怎么用的啊?
谢谢!!!
搜索更多相关主题的帖子: public return class print 
2008-10-13 22:30
zaneljp
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-6-29
得分:0 
回复 2# zacom 的帖子
嗯,谢谢啊~
2008-10-13 23:04



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




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

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