读书人

这个源程序中的Leaf increment()方法是

发布时间: 2012-01-19 20:57:58 作者: rapoo

这个源程序中的Leaf increment()方法是什么
class Leaf
{
private int i=0;
Leaf increment()
{
i++;
return this;
}
void print()
{
System.out.println("i= "+i);
}
}

public class Self
{
public static void main(String args[])
{
Leaf x=new Leaf();
x.increment().increment().increment().print();
}

}


这个源程序中的Leaf increment()方法是什么


[解决办法]
你这个是 小树 长高的 列子 程序吧

i++ 它的属性 自增 1
this 就是 Leaf本身。。。

读书人网 >J2SE开发

热点推荐