Jenkov.com
Tutorials About




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.util.Collection and java.util.Iterable. Additionally, the java.util.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 two java.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().



Connect with me: Newsletter - Get all my free tips!
     



Close TOC
This website uses cookies to improve the user experience and gather statistics. Our advertisers use cookies too (3rd party cookies), to provide more relevant ads. Continued use of this website implies that you accept the use of cookies on this website. We do not share our cookies with our advertisers, and our advertisers do not share cookies with us.
OK