两种写法均编译通过并正常运行
- public static void printColl(ArrayList<? extends Person1> al)
- { Iterator it = al.iterator();
- while(it.hasNext())
- ((Person1)it.next()).getName(); }
复制代码- public static void printColl(ArrayList<? extends Person1> al)
- {
- Iterator<? extends Person1> it = al.iterator();
- while(it.hasNext())
- it.next().getName();
- }
复制代码
|