What is a Java list?

In Java, a list interface is an ordered collection of objects in which duplicate values can be stored. Since a List preserves the insertion order, it allows positional access and insertion of elements.

List interface is implemented by the following classes:

Creating list objects

A list is an interface and the instances of a list can be created in the following ways:

  • listType is the class that is implementing the list interface.
  • objType is the data type of the values in the list
  • listName is the name of the list
// Obj is the type of object to be stored in List.
ListType<objType> listName = new ListType<objType> ();
Copyright ©2024 Educative, Inc. All rights reserved