Blog Archives
1 2 3 4

Java 8 using the Predicate functional interface

The java.util.function package in Java 8 has a number of functional interfaces. Let’s look at the Predicate interface that is used for filtering objects from a collection. Here is the Java 8 example: Step 1: Create a Driver domain class using the builder design pattern. … Read more ›...

Members Only Content
Log In Register Home


Java 8: 7 useful miscellaneous additions you must know

The much awaited addition in Java 8 are Lambda expressions to be used in functional programming and default and static methods in interfaces to support multiple behavior inheritance and helper methods. Here are a few other additional handy additions in Java 8. Addition #1: String.join( ) method, … Read more...

Members Only Content
Log In Register Home


Java 8: Different ways to sort a collection of objects in pre and post Java 8

The object we are going to sort is a Person. Option 1: Writing your own Comparator implementation. This can be done as an anonymous inner class instead of a separate class. The test class Option 2: The Option 1 is not bad, … Read more ›...

Members Only Content
Log In Register Home


Java 8: Does “Optional” class alleviate the pain of ubiquitous NullpointerException?

The most prevalent runtime exception (aka unchecked) exception in Java is the NullPointerException. You need to code defensively to avoid NullPointerException as shown below. Later, we will see how the class java.util.Optional that was introduced in Java 8 will alleviate this problem to some extent. … Read more ›...

Members Only Content
Log In Register Home


Java 8: What is currying? Does Java 8 support currying?

Currying (named after Haskell Curry) is the fact of evaluating function arguments one by one, producing a new function with one argument less on each step. Java 8 still does not have first class functions, but currying is “practically” possible with verbose type signatures, … Read more ›...

Members Only Content
Log In Register Home


Learning to write functional programming with Java 8 with examples

Scenario 1:  The Operation interface with the annotation @FunctionalInterface. This annotation ensures that you can only have a single abstract method. You can have additional default and static method implementations. Step 1: Define the interface. … Read more ›...

Members Only Content
Log In Register Home


Non-trival Java 8 tutorial to appreciate the power of functional programming (FP)

Prerequisite: Understanding of Java 8 streams.

Q. You have a list of key value pairs (“student name”, “subject”) as shown below.

Input

The required task is to list all the subjects for each student as shown below.

Result

A.

Read more ›



1 2 3 4

800+ Java Interview Q&As Menu

Learn by categories on the go...
Learn by categories such as FAQs – Core Java, Key Area – Low Latency, Core Java – Java 8, JEE – Microservices, Big Data – NoSQL, Architecture – Distributed, Big Data – Spark, etc. Some posts belong to multiple categories.
Top