1. Introduction In this article I will discuss how to assert an Optional. I have written a series of articles on Optional, which includes introduction, […]
Bridge between Array and Collection APIs
1. Overview Generally speaking, container is an object such as box which can be used to hold something. In programming container means the same thing. […]
Java Collections and its benefits
Collections aka containers are used to group objects into single entity. Once the objects are stored in a collection you can then perform operations on […]
How to use Boolean class Java 8 methods in Stream API
1. Introduction In this article, we will be go through the new methods added in Boolean class under package java.lang. Boolean class wraps up the […]
Convert array to List
1. Introduction In this article we will see how to convert an array i.e. primitive and object array to List. The following methods acts as […]
Reverse an array using 5 different ways
1. Introduction In this article we will see how to reverse the elements in a primitive array as well as in object array. We will […]
Convert List to array
1. Introduction In this post we will see how to convert List<E> to array in 4 different ways. The following methods acts as a bridge […]
What is Fail-Fast Iterator?
Fail-Fast iterators throw ConcurrentModificationException if the Collection is modified structurally. Fail-Fast iterators fail quickly and cleanly rather than risking the arbitrary non-deterministic behavior at undetermined […]
What is ConcurrentModificationException and why is it useful
ConcurrentModificationException is thrown by methods when they discover concurrent modification of object which such modifications are not permitted. So if the collection is modified structurally […]
Guide to Ints class of Google Guava
1. Overview Ints class in Google Guava provides several static utilities not available in Arrays or Integer class. As primitive types cannot be used as […]
6 different ways to Traverse/Iterate List in Java
1. Introduction In this article, we will see how to traverse the List in a few different ways. This includes traversing using Iterator and without […]
Java 8 Optional Code Smell
Optional<T> class encapsulates the optional value. Optional value means that either the value might or might not be present. It represents immutable container of non-null […]
Do not wrap Collection in Optional
1. Introduction Optional class was introduced in Java 8 to so as to provide a mechanism to represent whether a result is present or not. […]
Return Empty Collections and/or Unmodifiable Collections
1. Introduction In this article we will see about best practices for returning collections. It is common thing to return null from a method whose […]
Difference between Hashtable and HashMap
Below is the difference between Hashtable and HashMap: In terms of Null keys and Null values Hashtable does not allows null keys or values. If […]
7 different ways to Traverse Map
1. Introduction In this article, I will show you how to traverse the Map in 7 different ways. Map is an interface that stores key-value […]
Java code to Generate Fibonacci Series.
Embed from Getty Images Fibonacci Series: Fibonacci series is a series of numbers which are built up based on previous numbers. Example: f(1) – The […]
How to use join method of String class?
1. Introduction In this article, we will go through the new methods added in String class in Java 8 under package java.lang. A little about […]