The Map interface

In some situations, you need to store pairs of associated objects. For example, when counting the number of words in a text, the first one is a word and the second one is the number of its occurrences in the text. There is a special type of collections called map to effectively store such pairs of objects.


Resizable arrays One of the most widely used classes of Java Class Library is a class named ArrayList that represents a resizable array of objects of a specified type. Unlike the standard array denoted as [], it can dynamically grow after the addition and shrink after the removal of its elements. This behavior is very useful if you do not know the size of the array in advance…

The List interface

As you know, lists are the closest type to arrays, except their size can be changed dynamically while an array’s size is constrained. Moreover, lists provide more advanced behavior than arrays. In this topic, you will deepen your knowledge of lists and their relationship with the Collections Framework.

The Collections Framework overview

Java provides the collections framework which consists of classes and interfaces for commonly reusable data structures such as lists, dynamic arrays, sets, and so on. The framework has a unified architecture for representing and manipulating collections, enabling collections to be used independently of implementation details via its interfaces.

What are collections

When arrays are not enough The Java language supports arrays to store multiple values or objects of the same type together. An array is initialized with a predefined size during creation. The size cannot be changed in the future, and that imposes some limitations on their use for solving business problems. If we want to store more data, we need to create a new larger…

Concurrent queues

One of the most popular kinds of concurrent collections is a concurrent queue. It is often used to organize some kind of communication between multiple threads within an application by exchanging some data (messages, tasks, unit of works, or something else). To achieve it, several threads should have a reference to a common queue and invoke its methods. You already know that a queue is a…

Thread-safe maps

Welcome back, traveler, on your journey to the depths of concurrency! Remember one of your friends called HashMap? Today it’s time to know how to work with the key-value concept in a multithreaded environment. Thread-safe maps are quite popular. Imagine you implement a cache based on a map. You have two writer threads and one reader thread. If you use HashMap, there is no guarantee that the…


You are becoming a more experienced developer and conquering the peaks of multithreading. And today, our guest is the CopyOnWriteArrayList class, the member of the java.util.concurrent package. Look closely at the name: ArrayList plus the copy-on-write technique. Together, they give you a thread-safe representation of the ArrayList class.