泛型与迭代器
public List<Course> courses; //只能存放Course类型的对象
public TestGeneric(){
this.courses = new ArrayList<Course>();
}
public void testIterator(){
Iterator it = courses.iterator();
}
为什么泛型不能使用迭代器来遍历集合中元素呢?总会提示:Cannot convert from Iterator<Course>to HTMLDocument.iterator;还不能用Iterator<Course>这种方法来标注类型。