class Person
{
String name;
int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public void show(int a)
{
System.out.println(a);
}
}
class Student extends Person
{
String name;
int age;
public Student(String name, int age)
{
super(name, age);
}
public void show(int a)
{
super.show(a);
}
}
class PersonDemo
{
public static void main(String[] args)
{
Student s = new Student("lisi",3);
s.show(1);
}
}
在Student类中:
super(name, age); 为什么这不能写成super.Person(name,age);
super.show(a); 为什么这不能写成super(a);
为什么这两个地方的调用方式不一样?
|
|