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);
}
}
this调用构造方法那必须放在构造方法中的第一条语句
最新推荐文章于 2022-11-18 18:00:01 发布