java-examples

Java Almanac and Examples Collection

Back to Data StructuresArrays

Converting an Array to a Collection

// Fixed-size list
List list = Arrays.asList(array);

// Growable list
list = new LinkedList(Arrays.asList(array));

// Duplicate elements are discarded
Set set = new HashSet(Arrays.asList(array));

See also