java重复调用一个类的方法
package com.fc.test; /* * 看极光推送的服务器端的JDK源码 * 觉得比较好的,原来可以这样玩 */ public class Test { public Test() { } public static void main(String args[]) { int x = new Test2() .toT() .toT2() .toT3() .toT4() .getI(); System.out.println(x); } public static class Test2 { private int i = 0; public Test2() { } public Test2 toT() { System.out.println("Test2 ----->>> toT()"); i++; return this; } public Test2 toT2() { System.out.println("Test2 ----->>> toT2()"); i++; return this; } public Test2 toT3() { System.out.println("Test2 ----->>> toT3()"); i++; return this; } public Test2 toT4() { System.out.println("Test2 ----->>> toT4()"); i++; return this; } public void setI(int i) { this.i = i; } public int getI() { return this.i; }; } }