Add array to collection : Array Collections « Collections Data Structure « Java






Add array to collection

     


import java.util.Arrays;
import java.util.Collection;

public class Util{
  public static <T> void addArrayToCollection(T[] array, Collection<T> collection)
  {
    collection.addAll(Arrays.asList(array));
  }
}

   
    
    
    
    
  








Related examples in the same category

1.Array Iterator
2.Array MapArray Map
3.Array SetArray Set
4.Array Int Set
5.Remove duplicate element from array
6.Convert an Array to a List
7.Converting an Array to a Collection
8.Converting a Collection of user objects to an Array
9.Create an array containing the elements in a set
10.Convert an array to a Map
11.Converting a Collection of String to an ArrayConverting a Collection of String to an Array
12.Treating an Array as an Enumeration
13.ArrayEnumeration class (implements Enumeration)ArrayEnumeration class (implements Enumeration)
14.Custom ArrayMap implementation (extends AbstractMap)Custom ArrayMap implementation (extends AbstractMap)
15.Custom ArraySet implementation (extends AbstractSet)Custom ArraySet implementation (extends AbstractSet)
16.Converts array into a java.util.Map.
17.Growable array of intsGrowable array of ints
18.Growable array of floats.
19.Acts like an java.util.ArrayList but for primitive int valuesActs like an java.util.ArrayList but for primitive int values
20.Acts like an java.util.ArrayList but for primitive long values