Home » Java 8 » Page 5

Tag Archives: Java 8

Java 8 Collect vs Reduce Example

Hello readers, this tutorial explains the concept of reducing and collecting in Streams and Collector’s API respectively. 1. Introduction 1.1 Stream’s reduce() Method Let’s take a look at the Streams API’s reduce() method and how it can be used to perform reduction operations on the streams of data.         1.1.1 What is ‘reducing’ in the context of ...

Read More »

Java 8 Comparator Example

Hello readers, this tutorial explains how to use Lambda expressions in order to improve the boilerplate code of the Comparator written for sorting the list collections.                     1. Introduction The comparator interface has undergone a major overhaul in Java8 while still retaining its essence which is to compare and sort objects ...

Read More »

Java 8 Consumer and Supplier Example

Hello readers, this tutorial explains the in-built functional interfaces (i.e. Consumer<T> and Supplier<T>) introduced in Java8. 1. Introduction These features are the functional interfaces (i.e. an interface with only one abstract method) which belongs to the java.util.function package.           1.1 What is Consumer? Consumer<T> is an in-built functional interface introduced in Java8 in the java.util.function package. ...

Read More »

Java 8 Convert a Stream to List Example

Hello readers, this tutorial explains how to convert a Stream to a List with the help of the following examples. 1. Introduction One of the common problem while working with the Stream API in Java 8 is how to convert a Stream to List in Java because there is no toList() method present in the Stream class. When developers are ...

Read More »

Java 8 Streams: allMatch(), anyMatch(), noneMatch() Example

Hello readers, Java 8 Matching with Streams tutorial explains how to match the elements in a stream using the allMatch(), anyMatch() and noneMatch() methods provided by the Streams API.                 Table Of Contents 1. Introduction 1.1 Stream.allMatch() method 1.2 Stream.anyMatch() method 1.3 Stream.noneMatch() method 2. Java 8 Streams Example 2.1 Tools Used 2.2 ...

Read More »

Java Servlet Container Example

In this article we will demonstrate deploying and running a simple web application via a servlet container. In addition to demonstrating how to run the sample web application using a servlet container will also show how to run the sample web application using maven from the command line. For this article we will make use of Tomcat 8.5.x both for ...

Read More »

Java 8 Predicate Example

Hello readers, this tutorial explains Java 8 predicate example, which has been newly introduced in the java.util.function package. This package describes the Predicate’s usage with the help of multiple examples. 1. Introduction java.util.function.Predicate is the new functional interface defined in the java.util.function package. The Predicate is used in all the contexts where an object needs to be evaluated for a given ...

Read More »

Java Nio FTP Example

In this example we will demonstrate an FTP example program written in Java using some of the NIO features available to us. The example program will take the form of a command line program which accepts 2 arguments, namely the FTP location to transfer the file from and the local destination on the file system, inclusive of the file name, ...

Read More »

Java Servlet Cookie Methods Example

Servlets are modules of the Java code that run in a server application to answer the client requests. In this tutorial, we will show you how to store the user information in the cookie object and access it in the Servlet. 1. Introduction Servlet is a Java program which exists and executes in the J2EE servers and is used to ...

Read More »

Java Servlet Hidden Field Example

A hidden form field is a technique used to store the session information for a particular client and is one of an important Session Tracking Technique. In this tutorial, we will explain and show you how to handle the hidden fields in a Servlet. 1. Introduction Session Tracking is a technique to maintain the requests of the same user for a ...

Read More »