Fail-Safe Iterator vs Fail-Fast Iterator 1. Introduction In this article, we’ll introduce the concept of Fail-Fast and Fail-Safe Iterators. Fail-Fast systems abort operation as-fast-as-possible exposing failures immediately and stopping the whole operation. Whereas, Fail-Safe systems don’t abort an operation in the case of a failure. Such systems try to avoid… Continue Reading java-fail-safe-vs-fail-fast-iterator

Java – Combine Multiple Collections 1. Overview In this tutorial, we will illustrate how to concatenate multiple collections into one logical collection. We’ll be exploring five different approaches – two using Java 8, one using Guava, one using Apache Commons Collections, and one using only the standard Java 7 SDK.… Continue Reading java-combine-multiple-collections

Introduction to Eclipse Collections 1. Overview Eclipse Collections is another improved collection framework for Java. Simply put, it provides optimized implementations as well as some additional data structures and features which are not found in the core Java. The library provides both mutable and immutable implementations of all data structures.… Continue Reading eclipse-collections

Differences Between Collection.clear() and Collection.removeAll() 1. Overview In this quick tutorial, we’ll learn about two Collection methods that might seem to do the same thing, but aren’t: clear() and removeAll(). We’ll first see the method definitions and then use them in short examples. 2. Collection.clear() We’ll first dive into the Collection.clear() method. Let’s check… Continue Reading java-collection-clear-vs-removeall

A Guide to Apache Commons Collections CollectionUtils 1. Overview Simply put, the Apache CollectionUtils provides utility methods for common operations which cover a wide range of use cases and helps in avoiding writing boilerplate code. The library targets older JVM releases because currently, similar functionality is provided by the Java… Continue Reading apache-commons-collection-utils

Java Null-Safe Streams from Collections Java Java Collections Java Streams 1. Overview In this tutorial, we’ll see how to create null-safe streams from Java collections. To start with, some familiarity with Java 8’s Method References, Lambda Expressions, Optional and Stream API is required to fully understand this material. If you are… Continue Reading java-null-safe-streams-from-collections