Wednesday, February 19, 2025

Top 5 Udemy Courses to learn Functional Programming in Java in 2025 - Best of Lot

Hello guys, if you remember, Java 8 changed the way we usually code in Java by introducing some Functional Programming concepts. It brings features like lambda expressions and Streams, which give birth to new patterns that result in clean code in Java. Now there is a better and more declarative way to write Java. If you use them correctly, then they can express the intent of the code better and thus making it easier to read and maintain. There is another bit which many people miss is the introduction of Functional programming concepts like the map, reduce, flatmap, and filter, which enable us to write more readable code in Java.

Saturday, October 5, 2024

How to find the first element in Stream in Java 8? findFirst() Example

In Java 8, you can use the Stream.findFirst() method to get the first element of Stream in Java. This is a terminal operation and is often used after applying several intermediate operations e.g. filter, mapping, flattening, etc. For example, if you have a List of String and you want to find the first String whose length is greater than 10, you can use the findFirst() method along with stream() and filter() to get that String. The stream() method gets the Stream from a List, which then allows you to apply several useful methods defined in the java.util.Stream class like filter(), map(), flatMap() etc.

Tuesday, August 20, 2024

Top 12 Java 8 Stream Examples for Beginners

The java.util.stream.Stream class is one of the most useful class of Java 8 API. If I have to say that this is the class you would be using mostly while coding in Java 8 then it won't be an exaggeration. Since Stream class is integrated with Collection framework, you will end up using Streams for most of your day to day programming task in Java 8. It has several useful methods e.g. map() to convert one type of collection to other, flatMap to flatten a collection of collection, forEach to iterate over Collection, filter to selective remove elements from collection.