日期:2014-05-20 浏览次数:20736 次
class Person
{
protected String name;
public String talk()
{
return "我是一个包";
}
public Person()
{System.out.println("我是第一个包");}
}
class Student extends Person
{
public Student(String name)
{
this.name=name;
}
Student()
{System.out.println("我是第二个包");}
public String talk()
{
return "我是第二个包的类,"+this.name;
}
}
class TestPackage4
{
public static void main(String[] args)
{
Student s=new Student("javafans");
//s.name="javafans";
System.out.println(s.talk());
}
}