Home » core java » Page 6

Tag Archives: core java

Java 8 Filter Null Values from a Stream Example

Hello readers, in this tutorial, we will learn how to filter the null elements from a Stream in Java. 1. Introduction Java Stream is a sequence of elements that support the sum operations. In streams, the elements are reckoned on demand from different data sources such as Collections, Arrays or I/O resources and thus the elements are never stored. Streams ...

Read More »

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 Parallel Streams Example

Hello readers, Parallel Streams are the greatest addition to Java8 after Lambdas. This tutorial explains the parallel streams concept in detail. 1. Introduction The Stream API enables developers to create the parallel streams that can take advantage of multi-core architectures and enhance the performance of Java code. In a parallel stream, the operations are executed in parallel and there are ...

Read More »