程序错误:The type Person is already defined
程序清单:Student1.javaclass Person
{
public String name;
public int age;
public Person(String name,int age)
{
this.name=name;
this.age=age;
}
public Person() //如果不写这个构造函数,看看对类Student1有什么影响
{
}
public void getInfo()
{
System.out.println(name);
System.out.println(age);
}
}
class Student1 extends Person
{
public void study()
{
System.out.println("Studding");
}
public static void main(String[] args)
{
Person p=new Person();
p.name="person";
p.age=30;
p.getInfo();
Student1 s=new Student1();
s.name="student1";
s.age=16;
s.getInfo();
s.study();
}
}
程序错误: The type Person is already defined.
麻烦大家解释、修改一下。