In Java8, we can use following classes to find date time differences : Period Duration ChronoUnit Period We can use Period class to calculate difference in year, month, days between two Dates. Here is an example of using Period class methods getYears(), getMonths() and getDays() to calculate age of a person. package com.topjavatutorial; import …
Continue reading How to find date time differences in Java 8Java 8
In this article, we will discuss frequently asked Java 8 Interview Questions and Answers. You can refer the Part 1 using this link : Java8 Interview Questions : Part 1 Java 8 Interview questions 1. What are Static Interface Methods in Java 8 ? How are static Interface methods invoked ? JDK 8 added …
Continue reading Java 8 Interview Questions – Part 2Starting with Java 8, interfaces can define default method implementations. As of Java 8, whenever you have the choice of either, you should go with the defender (aka. default) method in the interface. Interface Default method advantage The constraint on the default method is that it can be implemented only in the terms …
Continue reading Interface with default methods vs Abstract class in Java 8Java 8 Predicate and Function Both Predicate and Function are predefined functional interfaces introduced in JDK 8. These are added in java.util.function package. Predicate Interface This is represented as Predicate<T> where T is an object type input. The purpose of Predicate<T> is to decide if the object of type T …
Continue reading Predicate vs Function in Java 8This post contains interview questions related to new features introduced in java 8 . What is a lambda expression ? What are advantages of lambda expression ? What is a functional interface ? What is the type of a lambda expression ? What is the target type of a lambda expression ? What is the …
Continue reading Top Java 8 Interview Questions and Answers