Optional Static Factories 1. Overview In this article we will discuss 3 different ways to create Optional object. Java has provided us with 3 different […]
Files class Find method
1. Overview In this article we will look at Files class’s find method. find() method returns the content of directory passed in parameter based on […]
Walking file tree using walk method of Files class.
1. Overview In this article we will look at Files class’s walk method. walk() method returns the content of directory passed in parameter. The contents […]
How toList all files in directory – 6 examples
1. Overview In this article we will look at Files class’s list method. list() method returns the content of directory passed in parameter. The contents […]
Read all lines of the file lazily in Java 8 with examples.
1. Read all lines of the file lazily lines() method allows us to read file line by line lazily i.e. It returns Stream<String>. 2. lines() […]
Read all lines of the file using Files.readAllLines method
1. readAllLines method Method signature readAllLines method is an overloaded method in Files class. Let’s first see the method version that added prior to Java […]
BufferedReader and BufferedWriter Methods in Java 8 with examples
1. Introduction In this article we will learn how to use newBufferedReader and newBufferedWriter method that was introduced in Files class in Java 8. There […]
What are empty collections & how to use it?
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 […]