- Back to Home »
- Java Collections Tutorial
The Java Collections API's provide Java developers with a set of classes and interfaces that makes it easier to handle collections of objects. In a sense Collection's works a bit like arrays, except their size can change dynamically, and they have more advanced behaviour than arrays.Rather than having to write your own collection classes, Java provides these ready-to-use collection classes for you. This tutorial will look closer at the Java Collection's, as they are also sometimes referred to, and more specifically the Java Collections available in Java 6.The purpose of this tutorial is to give you an overview of the Java Collection classes. Thus it will not describe each and every little detail of the Java Collection classes. But, once you have an overview of what is there, it is much easier to read the rest in the JavaDoc's afterwards.Most of the Java collections are located in the
java.util
package. Java also has a set of concurrent collections in the java.util.concurrent
package. This tutorial will not describe the concurrent collections. These will be described in their own tutorial some time in the future.Overview of Java Collections
To help you get an overview of the Java Collections classes and interfaces, the first text in this Java Collections tutorial is the Overview of Interfaces text.The Central Java Collection Interfaces
The third and fourth text explains the two central interfaces: java.io.Collection and java.io.Iterable. Additionally, the java.io.Map is central too.Java Collections and Generics
The fifth text in this Java Collections tutorial covers how to use Generics in Java Collections. Generics is very useful when working with Java's Collection classes.Java Collections and the equals() and hashCode() Methods
The last two texts in this Java Collections tutorial explains the central role the twojava.lang.Object
methods equals()
and hashCode()
play when using Java Collections. You should read this, if you plan to use Java Collections with your own classes, and thus need to implement equals()
and hashCode()
.