Here you can find the source of addAll(Collection collection, Iterator iterator)
Parameter | Description |
---|---|
collection | the collection to add to |
iterator | the iterator of elements to add, may not be null |
Parameter | Description |
---|---|
NullPointerException | if the collection or iterator is null |
public static void addAll(Collection collection, Iterator iterator)
//package com.java2s; /*// w ww .j av a 2 s .c om * Copyright (c) 2007-2016 AREasy Runtime * * This library, AREasy Runtime and API for BMC Remedy AR System, is free software ("Licensed Software"); * you can redistribute it and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either version 2.1 of the License, * or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * including but not limited to, the implied warranty of MERCHANTABILITY, NONINFRINGEMENT, * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. */ import java.util.*; public class Main { /** * Adds all elements in the iteration to the given collection. * * @param collection the collection to add to * @param iterator the iterator of elements to add, may not be null * @throws NullPointerException if the collection or iterator is null */ public static void addAll(Collection collection, Iterator iterator) { while (iterator.hasNext()) { collection.add(iterator.next()); } } /** * Adds all elements in the enumeration to the given collection. * * @param collection the collection to add to * @param enumeration the enumeration of elements to add, may not be null * @throws NullPointerException if the collection or enumeration is null */ public static void addAll(Collection collection, Enumeration enumeration) { while (enumeration.hasMoreElements()) { collection.add(enumeration.nextElement()); } } /** * Adds all elements in the array to the given collection. * * @param collection the collection to add to, may not be null * @param elements the array of elements to add, may not be null * @throws NullPointerException if the collection or array is null */ public static void addAll(Collection collection, Object[] elements) { for (int i = 0, size = elements.length; i < size; i++) { collection.add(elements[i]); } } }