Traditional Way of Performing Operation on Map: for (Map.Entry entry : SOME_MAP.entrySet()) {     if("somevalue".equals(entry.getValue())){ // Do Some Processing // Add Value to some list or Add the Value to list or Perform Some operation         System.out.println(“Result Found”)     } } Using Java 8 Stream API: Below Exa...

Read More

In our A Quick Tour of Java 8 Features  We have already discussed about all new features introduced in Java 8. Now in this article we will discuss more about new features like Lambda expressions and Streams.  Java 8 Lambda Expressions : Lambda expressions are new in Java 8. Lambda expressions are Java’s first step of entering into functional progra...

Read More

What are Functional interfaces ? Functional interfaces have a single functionality to achieve. Like the Runnable interface, the Callable interface and the Comparator interface, and a whole host of other interfaces already defined within Java—is what Java 8 calls a functional interface: It is an interface which requires exactly one method to be impl...

Read More

In our earlier Article about Java 8 Lamda Java 8: Lambdas, Part 1 , Get to know lambda expressions in Java 8 we have already discussed about the basic of Lambda expression introduced in Java 8. Here we will have some more discussion about Lamdas. A lambda in Java essentially consists of three parts: A parenthesized set of parameters. An arrow. And ...

Read More

Note: This post is inspired by and is an attempt at creating an extension to this post on Medium. As such, it will use some of the code in that post by Joel Planes. As a Java developer, the most common task we have to do is to write some server-side validations for our model data so as to validate the incoming objects to our application. Sure there...

Read More

Comparing the content of Lists against some condition is a common use case to handle in many business scenarios. This comparison can be broadly classified as: Comparing each element of a List against some condition. As an example, you have a List of Employee Objects and you need to check that all your Employees are above 18. One or more elements fr...

Read More

In Java 8 the most important library changes are made in Collection API and there is also a new addition named Stream. Streams allow us to write collections-processing code at a higher level of abstraction. The Stream interface contains a series of functions that we’ll explore throughout this tutorial, each of which corresponds to a common operatio...

Read More

The most frequent operation while working with collections is to iterate over a collection and perform some action on each element in turn. For example, Consider we have a List of Employees and we want to find the senior most and junior most employee from the List. So in normal boilerplate way we need to iterate over the List and identify the emplo...

Read More

One important operation that we often perform on Collection is partition it into two collections of values. For example, if you’ve got a Stream of Student, then you might wish to divide them based on gender. One approach to doing this is to perform two different filters, one looking for female students and the other for male students. This approach...

Read More

In this guide, we will see how to use Stream’s filter() method to filter a Map by keys and Values. With Java 8, you can convert a Map.entrySet() into a stream, followed by a filter() and collect() it. While filtering the Map we can provide logical operators like AND , OR to check condition on keys and values. Consider the following dummy data set f...

Read More

FOLLOW US ON LinkedIn



Explore Tutu'rself