class person
{
int age;
String name;
String country;
{
country="中国";
}
person(int age){
this.age=age;
this.name="佚名";
}
person(int age,String name){
this.age=age;
this.name=name;
}
public void say(){
System.out.println("我的名字"+name+",今年"+age+"岁,来自"+country+".");
}
}
class gouzhao1
{
public static void main(String[] args)
{
person p=new person(14);
//p.age=14;
//p.name="张三";
p.say();
}
}
构造函数
最新推荐文章于 2024-11-18 21:31:04 发布
1757

被折叠的 条评论
为什么被折叠?



