父类:
package Hello.lrx.nba;
import org.w3c.dom.ls.LSOutput;
public class Animal1 {
private int id;
private String name;
public void Move(){
System.out.println("动物走路");
}
}
子类:
package Hello.lrx.nba;
public class Dog extends Animal1{
public void move(){
System.out.println("狗走路");
}
}
主函数
package Hello.lrx.nba;
public class Main {
public static void main(String[] args) {
Dog dog = new Dog();
dog.move();
}
}
子类可以调父类以及修改父类,但父类不能调用子类