1. Overview Empty collections indicate that the collection does not have any values in it. All the empty collections are immutable which means once created […]
Implementing Functional Validators in Java
1. Introduction In previous article I discussed Tuple is an immutable collection or finite list of elements of same or different types. In this article, […]
Definitive Guide to Designing Tuple in Java 8 with 7 different methods
1. Introduction In this article, we will explore what is and how to write a Tuple in Java. Tuple is an immutable collection or finite […]
How to write Generics Methods and Varargs
1. Introduction This is third article in Java Generics. In previous articles I discussed about Introduction to Java Generics and cast guarantee provided in Generics. […]
How to create Immutable Objects with Example
Immutable objects are those objects that cannot be modified once created. Please read the first article in Immutable Objects series to understand what advantages are […]
Learn about 6 advantages of Immutable Objects.
Let me start this article by quoting Brain Goetz. Immutable objects are simple. They can only be in one state, which is carefully controlled by […]
3 static factory families of Collections class
1. Introduction java.util.Collections class is static utility class which contains polymorphic algorithms, static factories and wrapper methods. It also contains several other interesting methods. All […]
Generics Cast Guarantee
1. Introduction In previous article I wrote about Introduction to Java Generics. In this article we will see what cast guarantee is. Cast guarantee mean […]
Introduction to Java Generics
1. Introduction Generic programming means a code is written in terms of type which can be specified later and those types can be used as […]
Don’t put code block in Optional
1. Introduction In previous few articles we have seen how not to use Optional and explored few areas by refactoring code in better way rather […]
How to Sort HashMap according to keys
This article is going to very interesting as we will explore several different ways on how to sort a HashMap using keys. 1. Introduction Usually […]
How to get all numbers greater than x
1. Introduction Get all numbers greater than x where x is some number. For example, get all the numbers greater than 10. 2. Content We […]
Stream Interface’s methods one-liner description
1. filter(Predicate) Returns a stream consisting of elements of this stream which matches the given Predicate. 2. map(Function) Returns a stream consisting of elements that […]
How to use BufferedReader class Java 8 method lines()
1. Overview BufferedReader is a class that is used to read text from character input stream which provides efficient reading of characters, arrays and lines. […]
Iterable Interface Enhancements : What’s new in Java 8.
1. Overview Iterable interface provides a contract which is, if implemented the object will be allowed as a target of for-each loop. Collection interface extends […]
How to Add(Summation) all elements of an array
1. Overview In this article, we will see how to add all the elements of an array. For example we will use int[] array. Embed […]
Search for a value in an array
1. Overview In this article, we will see how to search for a value in an array. For example we will use int[] array. Embed […]
Java Collections Core Interfaces
Diagram built in BlueJ The core collection interfaces encapsulate different collections such as List, Set, Queue and Deque. Collections operate on generics. Collection Interface declaration […]
Search for a value in Object[] array
1. Overview In this article, we will see how to search for an object in an Object[] array. For example we will use String[] array. […]
Convert Iterator to Collection
1. Overview In this article I will write about converting an Iterator to Collection. Let us begin. Embed from Getty Images 2. Content Below are […]