package test; class Leaf{ int i = 0; //this是指向自身的引用,所以this.i是成员变量,i是形参。 Leaf(int i){this.i = i;} Leaf increament(){ i++; return this; } void print(){System.out.println("i="+i);} } public class Test { public static void main(String args[]){ Leaf leaf = new Leaf(100); leaf.increament().increament().print(); } }