Collections Basics
The collections classes we will look at in this chapter are all part of the Java Collections Framework. We will see that the best way to store data depends on our purpose – how many elements we want to store, whether we need things in sorted order, and how we would like to be able to search for individual elements. In the next course, CIS 300, you will learn much more about these different ways to store data (called data structures) – including how to implement these Java library classes. To use any of these classes, we need the following import statement:
import java.util.*;Generics
The Java Collections Framework makes use of a feature in Java called generics. The collections classes are written so that they can hold ANY type of elements we choose to store. When we create a new collections object, we must list the type of element that we’re storing. You will learn more about generics, including how to implement them in your own classes, in CIS 300.