多態理解

多態就是接口在不同實例的不同表現形式 就像打印機一樣有黑白的打印機,也有彩色的打印機   下面附一張照片 public class DT { public static void main(String[] args) { show(new Cat()); show(new dog()); Animal animal = new Cat(); //向上轉型 animal.eat(); Cat c
相關文章
相關標籤/搜索