1 public class Leaf { 2 3 int i = 0; 4 5 Leaf inceament() { 6 i++; 7 return this; 8 } 9 10 void print() { 11 System.out.println("i= " + i); 12 } 13 14 15 public static void main(String[] args) { 16 Leaf x = new Leaf(); 17 x.inceament().inceament().inceament().print(); 18 } 19 }
输出
i= 3
有几个inceament就输出几
原文:http://www.cnblogs.com/taoxiuxia/p/4438478.html