Converting between an Array and a List in Java 1. Overview This quick article is going to show how to convert between an Array and a List using core Java libraries, Guava or Apache Commons Collections. This article is part of the “Java – Back to Basic” series here on… Continue Reading convert-array-to-list-and-list-to-array

Time Complexity of Java Collections 1. Overview In this tutorial, we’ll talk about the performance of different collections from the Java Collection API. When we talk about collections, we usually think about the List, Map, and Set data structures and their common implementations. First of all, we’ll look at Big-O complexity insights… Continue Reading java-collections-complexity

Collections.emptyList() vs. New List Instance 1. Introduction In this short tutorial, we’ll illustrate the difference between Collections.emptyList() and a new list instance. 2. Immutability The core difference between java.util.Collections.emptyList() and a new list e.g. new ArrayList<>() is immutability. Collections.emptyList() returns a list (java.util.Collections.EmptyList) that can’t be modified. When creating a… Continue Reading java-collections-emptylist-new-list

Guide to CopyOnWriteArrayList 1. Overview In this quick article, we’ll be looking at the CopyOnWriteArrayList from the java.util.concurrent package. This is a very useful construct in the multi-threaded programs – when we want to iterate over a list in a thread-safe way without an explicit synchronization. 2. CopyOnWriteArrayList API The… Continue Reading java-copy-on-write-arraylist