Java List

The collection interface for an ordered sequence of elements that may contain duplicates, with ArrayList as the usual implementation.

In more detail

Elements keep the order they were added and are reachable by index. List.of creates an unmodifiable list; new ArrayList<>(...) creates a mutable one. Use a list when order or repetition is part of the contract.

Example

List<String> list = new ArrayList<>(List.of("a", "a"));

Related terms

Taught in

References

Certification courses