this调用构造方法那必须放在构造方法中的第一条语句

public class ThisQuoteTest
{
	String name;
	int age;
	String work;
	public ThisQuoteTest()
	{
		this("Lily",23,"teacher");
	}
	public ThisQuoteTest(String name,int age,String work)
	{
		this.name =name;
		this.age=age;
		this.work=work;
	}
	public ThisQuoteTest(String name,int age)
	{
		this.name =name;
		this.age=age;
	}
	public static void main(String args[])
	{
		ThisQuoteTest test=new ThisQuoteTest();
		System.out.println("My name is "+test.name+"I am "+test.age+"My work is "+test.work);
	}
	
}

你可能感兴趣的:(java)