Advanced Java Tutorial


Total available pages count: 55
Subject - Java Technologies

List interface

A List interface provides to maintain an ordered collection. It is known as the child interface of the Collection interface. It inhibits a list-type data structure where we can store an ordered collection of objects. It might have duplicate values.

Public interface List<E> extends Collection<E>

 

List <data-type> list1 =new ArrayList();
List <data-type> list2 =new LinkedList();
List <data-type> list3 =new Vector();
List <data-type> list4 =new Stack();

 

ArrayList

An ArrayList class implements a list interface. It used for a dynamic array to store duplicate elements of a different data type. ArrayList maintains the insertion order. The element from ArrayList can be randomly accessed. It is like an array with no size limit.

ArrayList list=new ArrayList(); //creating old non-generic arraylist
ArrayList<String> list=new ArrayList<String>(); //creating new generic arraylist

 

LinkedList

A LinkedList class implements a collection interface. It used for doubly LinkedList internally to store new & duplicate elements. It maintains insertion order & manipulates the element faster as there is no shifting required.

Vector

The vector used for a dynamic array to store the element. The vector is similar to ArrayList.it contains that might not part of the collection framework.

Stack

It is a subclass of vectors. stack implements the LIFO order of data structure. It contains all methods of vector & provides the method such as boolean push(), boolean push(Object o), boolean peek().



Comments