suggest change


A list is an ordered collection of values. In Java, lists are part of the Java Collections Framework. Lists implement the java.util.List interface, which extends java.util.Collection.



A list is an object which stores a an ordered collection of values. “Ordered” means the values are stored in a particular order–one item comes first, one comes second, and so on. The individual values are commonly called “elements”. Java lists typically provide these features:

Adding a value to a list at some point other than the end will move all of the following elements “down” or “to the right”. In other words, adding an element at index n moves the element which used to be at index n to index n+1, and so on. For example:

List<String> list = new ArrayList<>();
System.out.println(list.indexOf("world"));      // Prints "0"
// Inserting a new value at index 0 moves "world" to index 1
list.add(0, "Hello");
System.out.println(list.indexOf("world"));      // Prints "1"
System.out.println(list.indexOf("Hello"));      // Prints "0"

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents