Java帶你去看流浪世界!(十二)

抽象和接口 1.使用多態優化 多態:父類的引用能夠傳入任何子類的對象java 應用:web 1.父類的引用做爲方法的形參 public void toHospital(Pet pet){ } 2.父類的引用做爲方法的返回值類型 public Pet runPet(int choice){ if(){ return new Dog(); }else{
相關文章
相關標籤/搜索