Home » Java 8

Tag Archives: Java 8

Java 8 Functional Interface – BiPredicate Example

Hello. In this tutorial, we will explain the BiPredicate functional interface in Java 8. 1. Introduction Java 8 BiPredicate functional interface represents a method that accepts two input arguments and returns a boolean output. Represented by the method syntax – boolean test(T t, U u). This interface also provides some default methods like – default BiPredicate or(BiPredicate other) – Composed ...

Read More »

Summing Numbers with Java 8 Stream.reduce() operation

Hello. In this tutorial, we will explain the Stream.reduce method in java 8. 1. Introduction Before diving deep into the practice stuff let us understand the reduce() method in java8 programming. Stream.reduce() – Combine the elements of a stream and produces a single result. The method accepts T identity and BinaryOperator<T> accumulator as the arguments. If the identity argument is ...

Read More »

Java 8 Stream – findAny() & findFirst() Example

Hello. In this tutorial, we will explain the findAny() and findFirst() methods in java 8. 1. Introduction Before diving deep into the practice stuff let us understand the findAny() and findFirst() methods in java8 programming. Stream.findFirst() – Returns an optional object containing first element of the given stream. It can also return an empty() optional if the stream is emptyStream.findAny() ...

Read More »

Java 8 Stream – count() Example

Hello. In this tutorial, we will explain the count() method introduced in java 8. 1. Introduction Before diving deep into the practice stuff let us understand the count() method introduced in java8 programming. Stream.count() – Returns the number of elements in the stream with or without filter condition being appliedThis is a terminal operation and once consumed the same stream ...

Read More »

Java 8 Stream – min() & max() Tutorial

Hello. In this tutorial, we will explain the min() and max() methods introduced in java 8. 1. Introduction Before diving deep into the practice stuff let us understand the min() and max() methods introduced in java8 programming. Stream.min() – Returns the minimum element of the stream according to the provided comparator. Represented by the code syntax – Optional<T> min(Comparator<? super ...

Read More »

Java 8 Functional Interface – Consumer Example

Hello. In this tutorial, we will explain the Consumer functional interface in java 8. 1. Introduction Before diving deep into the practice stuff let us understand the Consumer functional interface in java programming. The interface: Contains the abstract accept() method and default andThen() method which can be used as an assignment for a lambda expression or method referenceAccepts a single ...

Read More »

Java 8 Stream – flatMap & Optional Example

Hello. In this tutorial, we will talk and understand the most commonly used Java 8 Stream APIs: the flatMap method and the Optional class. 1. Introduction Before diving deep into the practice stuff let us understand the flatMap method and Optional class in java programming. 1.1 flatMap() method This method is used to convert a stream of collections to a ...

Read More »

Java 8 Stream – Map & Collect Example

Hello. In this tutorial, we will explain the most commonly used Java 8 Stream APIs: the map() and collect() methods. 1. Introduction Before diving deep into the practice stuff let us understand the map and collect methods. 1.1 map() method This method is used to convert an object to something else. Represented by the syntax – map() method <R> Stream<R> ...

Read More »

Java 8 Stream – filter() & forEach() Example

Hello. In this tutorial, we will explain the most commonly used Java 8 Stream APIs: the forEach() and filter() methods. 1. Introduction Before diving deep into the practice stuff let us understand the forEach and filter methods. 1.1 forEach method This method is used to iterate the elements present in the collection such as List, Set, or Map. It is ...

Read More »

Java 8 vs Java 12

In this article, we will see a comparison of the Java 8 vs Java 12. 1. What is Java? Java is a programming language first released by Sun Microsystems in 1995. There are lots of applications and websites that will not work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From ...

Read More »