package com.nanjing;
public class Animal {
protected int id;
protected String name;
public Animal(int id,String name){
this.id = id;
this.name = name;
}
public void show(){
System.out.println("父类:" + this.id + this.name);
}
public final void hello(){
System.out.println("不允许重写了~");
}
}
package com.nanjing;
public class Dog extends Animal{
private String gender;
public Dog(int id,String name,String gender){
super(id, name);
this.gender = gender;
}
public void show(){
System.out.println("子类:" + this.id + this.name + this.gender);
super.show();
super.hello();
}
public static void main(String[] args){
Dog d = new Dog(1,"狗","F");
d.show();
}
}