多态理解

多态就是接口在不同实例的不同表现形式 就像打印机一样有黑白的打印机,也有彩色的打印机   下面附一张照片 public class DT { public static void main(String[] args) { show(new Cat()); show(new dog()); Animal animal = new Cat(); //向上转型 animal.eat(); Cat c
相关文章
相关标签/搜索