Collection的由来
在讲List之前,先简要介绍一下Collection
Collection继承了一个叫做Iterable的接口,里面包含属性Iterator
而Iterator接口中定义了3个方法:hasNext(),next(),remove()
其中remove方法没有返回值,作用为将迭代器新返回的元素删除
官方注释为:Removes from the underlying collection the last element returned by this iterator
本文介绍了Java集合框架中Collection的基本概念及其与Iterable接口的关系。详细解释了Iterator接口的三个核心方法:hasNext(), next() 和 remove() 的作用及其实现原理。
3027





