[求助]java代码的意思?
class Person{
public static void prt(String s)
{
System.out.println(s);
}
Person()
{
System.out.println("l Person.");
}
Person(String name)
{
System.out.println("A person name is:"+name);
}
}
public class Chinese extends Person{
Chinese(){
super(); //调用父类构造函数(1)
System.out.println("A chinese.");//(4)
}
Chinese(String name){
//super(name);//调用父类具有相同形参的构造函数(2)
System.out.println("his name is:"+name);
}
Chinese(String name,int age){
this(name);//调用当前具有相同形参的构造函数(3)
System.out.println("his age is:"+age);
}
public static void main(String[] args){Chinese cn=new Chinese();
new Chinese("kevin");
cn=new Chinese("kevin",22);
}
}
结果为什么是这个样子,
l Person.为什么会出现3次
谢谢!