摘要: 1 Object o = myArrayList.get(0);2 Dog d1 = (Dog) o; //将类型转换成Dog3 d1.eat();4 if (o instanceof Dog) {5 Dog d2 = (Dog) o;6 d2.eat();7 } 阅读全文
posted @ 2013-09-11 15:34 boom boom pow 阅读(182) 评论(0) 推荐(0)
摘要: 如果对象的类型是Dog,而引用它的却是Object,则它不能调用Dog的方法。 阅读全文
posted @ 2013-09-11 15:05 boom boom pow 阅读(108) 评论(0) 推荐(0)
摘要: 今天学习object类型的多态时遇到了get(0)这个东西,不懂是什么意思。附上代码:import java.util.*;public class Dog { String name; public void eat() { System.out.println("吃骨头"); } public static void main(String[] args) { ArrayList test = new ArrayList(); Dog a = new Dog(); test.add(a); Dog d = test.get(0);//此处惊现疑云 }... 阅读全文
posted @ 2013-09-11 14:45 boom boom pow 阅读(889) 评论(0) 推荐(0)
摘要: 抽象的类代表此类必须要被extend过,抽象的方法代表此方法一定要被覆盖过。--抽象类和抽象方法都是没有实际用处的,如果不加以extend或者overload,那么写这个抽象的东西干嘛呢? 阅读全文
posted @ 2013-09-11 02:23 boom boom pow 阅读(125) 评论(0) 推荐(0)
摘要: I'm so glad I love Pop.and I'm sure I'm gonna perfectly follow the spirit of pop.BTW,anything associate with my important stuff ,like ACM,poomsae,embedded development,I will use popjohn as my ID.Let's pop it up! 阅读全文
posted @ 2013-05-14 10:12 boom boom pow 阅读(151) 评论(0) 推荐(0)