Home » You searched for java 8

Search Results for: java 8

Java Stream – How to use Java 8 streams

1. Introduction In this post, we will learn about how to use a Stream in Java, which was introduced as part of Java 8 version. Let us understand what actually the word streaming means with an example and what the java 8 API provides with regard to methods. When you start watching a video, a small portion of the file ...

Read More »

Migrating from Java 8 to Java 13

In this article, we will demonstrate how to migrate an application from Java SE 8 to Java SE 13. 1. Introduction Oracle began a six-month release cadence for Java Standard Edition starting with Java 10. Instead of being major version releases, they are instead “feature releases”. This release cycle is in the spirit of Continuous Integration / Continuous Deployment and ...

Read More »

Java String Methods from Java 8 to Java 14

In this article, we will look at the new string methods added to the Java API from versions 8 to 14. 1. Java String Methods – Java 8 The newly added method in Java 8 is join for joining up the various strings. Let us see the methods with an example: public class StringDemo { public static void main(String[] args) ...

Read More »

Java 8 Functional Interfaces Introduction Example

Hello readers! In this tutorial, we will learn the amazing feature of Java 8 Functional Interfaces. 1. Introduction To achieve the benefits of functional programming in Java, JDK developers introduced Functional Interfaces/Single Abstract Method (SAM) Interfaces in Java 8 programming. A functional interface is an interface that has only one abstract method A functional interface can have multiple default and ...

Read More »

Java 8 Lambda Expressions Introduction Example

Hello readers! In this tutorial, we feature a comprehensive article on Java 8 Lambda Expressions.  1. Introduction To achieve the benefits of functional programming in Java, JDK developers introduced Lambda Expressions in Java 8 programming. A lambda expression is a nameless function which does not have the name, return type, and access modifiers A lambda expression instance can be assigned ...

Read More »

Java 8 Optional In Depth Example

1. Introduction This is an in-depth article about Java 8 Optional. A new class Optional was introduced in Java 8. The optional class is part of java.util package. Optional is used to represent a value. It can be present or absent. No more null checks and NullPointerException are needed. Optional helps in avoiding any runtime NullPointerExceptions. It helps in developing clean ...

Read More »

Java 8 Functional Programming Tutorial

Java 8 supports functional programming via the lambda expression and Stream API. In this tutorial, I will demonstrate how Java 8 supports functional programming via common pre-defined functional interfaces, Collections, and Stream API.                 Table Of Contents 1. Introduction 2. Technologies Used 2.1 Maven Project 3. Java 8 Predefined Functional Interfaces 3.1 Function ...

Read More »

Java 8 Format LocalDateTime Example

1. Introduction Java 8 Date-time API provides a java.time.LocalDateTime class which is an immutable date-time object and often is viewed as a year-month-day-hour-minute-second format. It contains a java.time.format package to handle the formatting of dates and times. This package includes three classes: DateTimeFormatter – to print and parse date-time objects. It provides common formatting constants as well as a string ...

Read More »

Java 8 Compare Dates Example

1. Introduction Java 8 added a new set of packages to provide a comprehensive date-time model. Java 8 Date-Time API is a JSR-310 implementation.                   There are several interfaces: ChronoLocalDate, ChronoLocalDateTime, ChronoZonedDateTime in java.time.chrono packages. They all have isBefore, isAfter, isEquals, and compareTo methods to compare two dates. Java 8 date classes: ...

Read More »

Java 8 Stream Collectors groupingBy Example

1. Introduction SQL GROUP BY is a very useful aggregation function. It groups database records on certain criteria. Java 8 Stream API enables developers to process collections of data in a declarative way. Java 8 Collectors class provides a static groupingBy method: to group objects by some property and store the results in a Map instance. It has three signatures, which ...

Read More »