您的位置:首页 > 其它

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

2014-01-09 16:32 330 查看
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);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐