Convenience Factory Methods for Collections

Java 9 introduced the Convenience Factory Methods for Collections that make it convenient to create instances of collections or maps with few elements

April 27, 2020

ListIterator in Java with examples

A ListIterator in Java is an Iterator that allows us to traverse the list in either direction, modify the list during iteration, and obtain the iterator’s current position in the list.

March 30, 2020

Effective Java's Builder Pattern

Introduction In the last post, I wrote about the Gang of Four (GoF) Builder Design Pattern. In this post, we will look at the builder pattern from the Effective Java…

March 2, 2020

Enumeration and Iterator in Java

Java has two ways to iterate over the elements of a collection - using an Enumeration and an Iterator. This post explains Enumeration and Iterators in Java.

January 7, 2020

Optional – New methods in Java 9 through 11

Optional was added to Java 8. This post explains the new methods or APIs added to the Optional class in Java from Java 9 through 11 with examples.

November 18, 2019

A Complete Guide to Java Optional

Optional is a container object added to Java 8+ that is used as a wrapper over some value. It provides a mechanism to represent “no result” for a method.

November 11, 2019

Three Ways to Sort a List in Java

In this blog post, we will see three ways to sort a list in Java. We will see how to sort in ascending and in reversed order.

October 13, 2019

TreeMap in Java with Examples

A TreeMap is a Red-Black Tree based implementation of a NavigableMap. In this post, we will look at TreeMap in Java and the methods offered by them.

July 31, 2019

How Hashmap Works in Java

A Map data structure is an object that maps keys to values. We will see how a HashMap works in java. We will also see how get and put operations work.

July 22, 2019

Benefits of Immutable Class in Java

An immutable class is a class whose instances cannot be modified after it is created. In this post, we will look at the benefits of immutable class in Java.

June 29, 2019