java例程练习(this关键字的使用)

public class Test {

	int i = 0;
	
	Test(int i) {
		this.i = i;
	}
	
	Test increament() {
		i++;
		return this;
	}
	
	void print() {
		System.out.println("i = " + i);
	}
	
	public static void main(String[] args) {
		Test t = new Test(100);
		t.increament().increament().print();
	}
}

你可能感兴趣的:(java,String,Class)