Newsletter:

(Tutorial) Java Collection Framework (Lists)

Tutorial : Java Collection Framework (Lists)

Introduction
Collection is defined as several things grouped together.

Java collection framework is made up of various interfaces to work with different groups. Implementation of the interfaces allow us to do our job but this means that data structure can be changed without changing the code.

Java.util package contains an interface called Collection. Collection is an interface which means it defines abstract methods (methods without body). The classes implementing this interface will define the implementation for the abstract methods in the Collection interface.

Subclasses
Following are the list of classes that implement Collection interface:

AbstractCollection, AbstractList, AbstractSet, ArrayList, BeanContextServicesSupport, BeanContextSupport, HashSet, LinkedHashSet, LinkedList, TreeSet, Vector

Each of these class, defines its own implementation of Collection interface. Of course, each abstract method is implemented in these classes.

Subinterfaces
Collection interface has following subinterfaces:
BeanContext, BeanContextServices, List, Set, SortedSet

These interfaces extends Collection.

List Interface
The classes implementing the List interface are:
AbstractList, ArrayList, LinkedList, Vector

List is an ordered collection of object. Ordered means in a sequence. So use can add item to a list at a certain position(index) and can retrieve the item from that very position. Also, duplicates are allowed in a List...

[Read More..]

Courtesy:- Java-forums.org