设计模式课程 设计模式精讲 5-3 工厂方法源码解析

1    源码解析

1.1  collection的iterator解析

1    源码解析

1.1  collection的iterator解析

Collection:

Iterator<E> iterator();

    /**
     * Returns an array containing all of the elements in this collection.
     * If this collection makes any guarantees as to what order its elements
     * are returned by its iterator, this method must return the elements in
     * the same order.
     *
     * <p>The returned array will be "safe" in that no references to it are
     * maintained by this collection.  (In other words, this method must
     * allocate a new array even if this collection is backed by an array).
     * The caller is thus free to modify the returned array.
     *
     * <p>This method acts as bridge between array-based and collection-based
     * APIs.
     *
     * @return an array containing all of the elements in this collection
     */

HashMap

 public Iterator<Map.Entry<K,V>> iterator() {
            return newEntryIterator();
        }

猜你喜欢

转载自www.cnblogs.com/1446358788-qq/p/11285027.html