Collections in Java

A collection is a general term that means something like "a bunch of objects
stored in a structured manner". Java has various standard collection classes and using collections in
Java allows you to organise data in memory in various convenient ways. Examples might include:

a simple list of strings;

a mapping or association of strings to strings (e.g. country names to the names of their capitals);

a list that imposes some constraint, e.g. keeping strings in alphabetical order, or not allowing duplicates in the list.

The Java Collections Framework— often called simply (Java) Collections—
is a library of classes that implement these and various other data structures.
The collections framework also provides utility methods to perform functions
such as sorting a list of data.

How to start learning about and using Java collections

There are a couple of ways to approach collections in Java, covered by the
collections tutorials in the rest of this section:

if you just need a collection of "standard" objects (boring old Strings,
Numbers etc provided by the Java class libraries),
then you can take a fairly practical approach and start using
the standard collections classes without worrying too much about how they work– we'll take a practical look at
lists, sets and maps.

if you need to store instances of your own class in some types of collection,
then you will generally need to understand a little bit (but not all
the details) about how they work, in particular how HashMaps work
via the technique of hashing– however,
you may wish to consult this site's hash function guidelines
if you don't want to get too bogged down in the theory;

in some cases, you may need to have a fuller understanding about how collection classes
work in order to make decisions relating to performance.