Home » Java 8 » Page 4

Tag Archives: Java 8

Java 8 Map Sorting Example

Hello readers, in this tutorial, we will learn how to Sort a Map using Java8 Stream’s API and Lambda expression. 1. Introduction These days in the programming universe sorting a map is one of the most habitual tasks in Java. In the ancient Java world, developers could sort a Map either by its keys or values. In Java8, JDK developers ...

Read More »

Java Read File Line by Line Example

Hello readers, in this tutorial, we will see an example of how to Read a File Line by Line in Java 8. We will learn the Java 8 Stream’s API for reading a file’s content line by line and we will explore its different characteristics. 1. Introduction These days in the programming universe reading the file content is one of ...

Read More »

Java 8 StringJoiner Example

Hello readers, in this tutorial, we will learn about the Java8 Stream’s API StringJoiner feature and we will explore its different characteristics. 1. Introduction These days in the programming universe joining multiple strings are a common task among the developers. In the ancient Java world, there was no direct way to join the multiple strings. Java8 has introduced a final ...

Read More »

Java 8 flatMap Example

Hello readers, in this tutorial, we will learn about Java8 Streams API flatMap() method and in which structure it can be used. 1. Introduction A flatMap() method is a Java8 programming operation which takes a single function as an argument. This function accepts the T parameter as an input argument and returns a stream of R parameter. When this function ...

Read More »

Java 8 Convert a List to Map Example

Hello readers, in this tutorial, we will learn how to convert a List<?> to a Map<K,V> using Java8 Streams API. 1. Introduction The most common task in Java programming is to convert a List of the object e.g. List<?> into a Map e.g. Map<K,V> where K is some property of the object and V is the real object. For e.g., ...

Read More »

For Each Loop Java 8 Example

In this post, we feature a comprehensive For Each Loop Java 8 Example. Foreach method, it is the enhanced for loop that was introduced in Java since J2SE 5.0. Java 8 came up with a new feature to iterate over the Collection classes, by using the forEach() method of the Iterable interface or by using the new Stream class. In ...

Read More »

Java 8 Convert an Array to List Example

Hello readers, in this tutorial, we will learn to convert the primitive array to list using the Java8 Stream API. 1. Introduction Converting an Array of data into an equivalent List does seem like one of the simplest tasks which a programmer would do when coding in Java. There are many scenarios where the data is present in an Array, ...

Read More »

Java 8 LocalDateTime Example

Hello readers, Java provides a new Date and Time API in Java8. This tutorial demonstrates how to use the LocalDateTime class with few important methods defined in this class.                 1. Introduction The java.time.LocalDateTime is a new class introduced on the Java8 Date and Time API. This immutable class is in java.time package ...

Read More »

Java 8 Method Reference Example

Hello readers, Java provides a new feature called method reference in Java8. This tutorial explains the method reference concept in detail. 1. Introduction Lambda Expression allows developers to reduce the code compared to the anonymous class in order to pass behaviors to the methods, Method Reference goes one step further. It reduces the code written in a lambda expression to ...

Read More »

Java Servlet and JSP Example

In this article we will demonstrate a simple Servlet and JSP example using the maven cargo plugin from the command line. We will also cover, albeit briefly, the functioning of both Servlet and JSP constructs within the Servlet Container in terms of how they are used to satisfy a HTTP request. The sample application will greet you with your name, ...

Read More »