Topic: 初学者初来咋到问个初级的问题

  Print this page

1.初学者初来咋到问个初级的问题 Copy to clipboard
Posted by: headrock
Posted on: 2003-08-11 13:36

public class ThisTest
{
  int i = 0;
  ThisTest increment()
  {
    i++;
    return this;
  }
  void print()
  {
    System.out.println("i = " + i);
  }
  public static void main (String[] args)
  {
    ThisTest x = new ThisTest();
    x.increment().increment().increment().print();
  }
}
为什么结果是 i=3
请大侠帮解释一下 谢谢

2.Re:初学者初来咋到问个初级的问题 [Re: headrock] Copy to clipboard
Posted by: heaven
Posted on: 2003-08-12 20:24

奇怪,加三次不等于3还能等于几?你有什么疑问?


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923