Introduction
In this article first, we introduce the collection framework. Since we have also written an article previously about the collection framework, in this article we only provide a definition of the collection framework, its hierarchy structure and details of its List Interface.

The Collections Framework provides a set of interfaces and classes for storing and manipulating groups of data as a single unit; a collection. And it provides a convenient API to many of the abstract data types data structure curricula: maps, sets, lists, trees, arrays, hashtables and other collections. Because of their object-oriented design, the Java classes in the Collections Framework encapsulate both the data structures and the algorithms associated with these abstractions.
List Interface
The Java Collection framework is mainly divided into interfaces and abstract classes so the List is an interface and it contains the following abstract methods:

Note: The
List interface extends the Collection interface to define an ordered collection, permitting duplicates. The interface adds position-oriented operations, as well as the ability to work with just a part of the list.Example 1
- import java.util.*;
- public class ListDemo
- {
- public static void main(String args[])
- {
- List list = new ArrayList();
- list.add("abhishek");
- list.add("Mani mishra");
- list.add("Neha");
- list.add("Arun");
- list.add("Aditya");
- System.out.println(list);
- System.out.println("2: " + list.get(2));
- System.out.println("0: " + list.get(0));
- LinkedList queue = new LinkedList();
- queue.addFirst("Omji");
- queue.addFirst("abhishek");
- queue.addFirst("Arun");
- queue.addFirst("subham");
- queue.addFirst("Maneesh");
- System.out.println(queue);
- queue.removeLast();
- queue.removeLast();
- System.out.println(queue);
- }
- }

Example 2


Join the conversation! Your thoughts help the community grow.