您的位置:首页 > 其它

在构造方法中调用当前类的构造方法

2014-01-03 16:06 120 查看
public class ThisTest
{
String name;
int age;
public ThisTest()
{
this("rach");
System.out.println("My name is :"+this.name+" and I am "+this.age+" years old");

}
public ThisTest(String name)
{
this.name=name;
this.age=26;
}
public static void main(String args[])
{
ThisTest test=new ThisTest();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: