Java List Interface extends Collection interface. The list interface is used to store and manipulate items. Insertion and deletion are positional based, and the list can have duplicate items in it. In general, it is used to store lists of objects and preserves the order. List Interface is implemented by  ArrayList,  LinkedList,  Vector, and  Stack classes.

Java List Interface

The List interface places additional stipulations, beyond those specified in a Collection interface, on the contracts of an iterator, add, remove, equals, and hashCode methods.

Declarations for other inherited methods are also included here for convenience. The ordered collection which is also known as a sequence.

The user of this  interface has precise control over where in the list, each element is inserted. The user can access items by their integer index (position in the list), and search for elements in the list.

Unlike sets, lists typically allow duplicate elements. More formally, lists usually allow pairs of elements e1 and e2 such that e1.equals(e2), and they usually allow multiple null items if they allow null items at all.

It is not that inconceivable that someone might wish to implement the list that prohibits duplicates, by throwing the runtime exceptions when a user attempts to insert them, but we expect this usage to be rare.

#java #collection #linkedlist #arraylist #vector

Java List Interface Example | List Interface In Java Tutorial
1.50 GEEK