21 January, 2015

Java - List and sub classes

List interface in Java is one of the very commonly used Collection Interface. 
We will look at important sub classes and methods of List Interface.

 


When we have a requirement of storing a group of objects where
a) Duplicates are allowed
b) Insertion order needs to be preserved.

Then List is the Collection you would need to look out for.
[ Insertion order and Duplicates ]

Lets have a look at come of the key methods in java.util.List interface.

1) add
2) remove
3) isEmpty
4) size
5) contains
6) clear
7) get
8) set
9) iterator

There methods would allow you to perform all the required operation with Lists.

Now Lets  have a look at some of the important sub classes for List.

2) LinkedList
3) Vector
4) Stack

To learn more on each of these classes, click on the respective classes