class Person
{
String name;
int age;
public void speak(String name,int age)
{
System.out.println ("name="+name+"age="+age);
}
}
class Student extends Person
{
void study()
{
super.speak("张同学",23);
}
}
class Worker extends Person
{
void work()
{
super.speak("于师傅",35);
}
}
class PersonDemo
{
public static void main(String[] args)
{
Student s= new Student();
Worker w = new Worker();
s.study();
w.work();
}
}
刚回去琢磨了下,重新写出来了,谢谢各位的回复,学习了 |