Java Collections list() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
java.util.Collections

Definition

In Java, Collections.list(e) reads an Enumeration from start to finish and returns a brand-new ArrayList containing its elements in the same order.

It is the bridge from old APIs (Vector, Hashtable, StringTokenizer, some servlet methods) to modern collection code, where you can sort, filter, and loop with for-each.

A static method of the java.util.Collections utility class, available since Java 1.4. Call it on the class name, as in Collections.list(...), after import java.util.Collections;. You never create a Collections object.

Syntax

Pass the enumeration; you get an ArrayList, not just a List.

Java
ArrayList<String> items = Collections.list(vector.elements());
ArrayList<Object> words = Collections.list(new StringTokenizer("a b c"));
CallWhat it does
Collections.list(e)New ArrayList with every remaining element of e.
Collections.enumeration(c)The opposite direction: collection to Enumeration.
new ArrayList<>(vector)If you already hold the collection, copy it directly.

Available since Java 1.4. The return type is the concrete class ArrayList<T>, so the result is fully changeable and independent of the source.

Library declarations
Java
// java.util.Collections
public static <T> ArrayList<T> list(Enumeration<T> e)

Parameters

ParameterDescription
eThe enumeration to drain. Must not be null.

Return Value

Return ValueDescription
ArrayList<T>A new list with the elements in the order the enumeration returned them.

Compare with Similar Methods

Related conversions:

MethodHow it differs
enumeration(c)Collection to Enumeration.
emptyEnumeration()An enumeration that yields nothing; list of it is [].
ArrayListThe type of list this method returns.

Java Examples

Example 1 — Turn Vector.elements() into an ArrayList

Copy a legacy Vector into an ArrayList, sort and extend the copy, and leave the Vector alone.

Java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Vector;

public class CollectionsListVector {
    public static void main(String[] args) {
        Vector<String> legacy = new Vector<>(Arrays.asList("pear", "apple", "fig"));
        ArrayList<String> modern = Collections.list(legacy.elements());

        Collections.sort(modern);
        modern.add("kiwi");
        System.out.println("copy:   " + modern);
        System.out.println("vector: " + legacy);
    }
}

How It Works

  1. Old API. Vector.elements() returns an Enumeration, not an iterator.
  2. Copy out. Collections.list drains it into a new ArrayList, which we sort and then append "kiwi" to.
  3. Independent. The Vector still holds its original three fruits in the original order.

Example 2 — Collect StringTokenizer Tokens

StringTokenizer implements Enumeration<Object>, so its tokens can be collected in one call.

Java
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class CollectionsListTokens {
    public static void main(String[] args) {
        ArrayList<Object> words = Collections.list(new StringTokenizer("red green  blue", " "));
        System.out.println(words + " size " + words.size());

        ArrayList<Object> cells = Collections.list(new StringTokenizer("a,b,,c", ","));
        System.out.println(cells + " size " + cells.size());
    }
}

How It Works

  1. Element type Object. StringTokenizer is an Enumeration<Object>, so the result is an ArrayList<Object>.
  2. Runs of delimiters. The double space between "green" and "blue" does not create an empty token.
  3. Same for commas. "a,b,,c" gives three tokens; StringTokenizer skips the empty field between the two commas.

Example 3 — An Enumeration Can Only Be Read Once

Call Collections.list twice on the same enumeration, then show the result is a normal, changeable list.

Java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;

public class CollectionsListConsumed {
    public static void main(String[] args) {
        Enumeration<Integer> e = Collections.enumeration(Arrays.asList(1, 2, 3));
        ArrayList<Integer> first = Collections.list(e);
        ArrayList<Integer> second = Collections.list(e);
        System.out.println("first:  " + first);
        System.out.println("second: " + second);

        first.add(4);
        System.out.println("first can grow: " + first);
    }
}

How It Works

  1. First call drains. The first Collections.list reads all three numbers.
  2. Nothing left. The enumeration has no way to rewind, so the second call returns an empty list.
  3. Regular ArrayList. The returned list is not read-only; adding 4 works.

Frequently Asked Questions

It copies all remaining elements of an Enumeration into a new ArrayList and returns it.
Yes. It is an ordinary ArrayList that is independent of the source.
You can, but the second call returns an empty list because the first one consumed every element.
Collections.list(new StringTokenizer(text)) returns an ArrayList<Object> of the tokens.
Java 1.4.

Next: max()

Return the largest element of a collection.

max() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful