Guide to Apache Commons CircularFifoQueue 1. Overview In this quick tutorial, we’ll have a look at the CircularFifoQueue data structure provided in the collections4.queue package of the Apache Commons Collections library. CircularFifoQueue<E> implements the Queue<E> interface and is a fixed-size, non-blocking queue — when you add an element to a… Continue Reading commons-circular-fifo-queue

Zipping Collections in Java 1. Introduction In this tutorial, we’ll illustrate how to zip two collections into one logical collection. The “zip” operation is slightly different from the standard “concat” or “merge”. While the “concat” or “merge” operations will simply add the new collection at the end of the existing… Continue Reading java-collections-zip

Shuffling Collections In Java 1. Overview In this quick article, we’ll see how we can shuffle a collection in Java. Java has a built-in method for shuffling List objects — we’ll utilize it for other collections as well. 2. Shuffling a List We’ll use the method [.pl-smi]#java.util.Collections.shuffle[.blob-code-inner][.pl-smi], which ###takes as… Continue Reading java-shuffle-collection

Guava – Join and Split Collections 1. Overview In this tutorial, we will learn how to use the Joiner and Splitter in the Guava library. We’ll convert collections into a String with the Joiner and we’ll split a String into a collection with the Splitter. 2. Convert List into String… Continue Reading guava-joiner-and-splitter-tutorial

Primitive Collections in Eclipse Collections 1. Introduction In this tutorial, we’ll talk about primitive collections in Java and how Eclipse Collections can help. 2. Motivation Suppose we want to create a simple list of integers: List<Integer> myList = new ArrayList<>; int one = 1; myList.add(one); Since collections can only hold… Continue Reading java-eclipse-primitive-collections

Filtering and Transforming Collections in Guava 1. Overview In this tutorial, we’ll illustrate how to filter and transform collections with Guava. We will filter using Predicates, transform using the Functions that the library provides and finally, we’ll see how to combine both filtering and transforming. Further reading: New Stream, Comparator… Continue Reading guava-filter-and-transform-a-collection

Introduction to PCollections 1. Overview In this article, we will be looking at PCollections, a Java library providing persistent, immutable collections. Persistent data structures (collections) can’t be modified directly during the update operation, rather a new object with the result of the update operation is returned. They are not only… Continue Reading java-pcollections