Home » core java » Page 7

Tag Archives: core java

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 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 »

Apache ActiveMQ Distributed Queue Tutorial

Apache ActiveMQ (AMQ) is an open source messaging server written in Java, which implements JMS 1.1 specifications. In this article, I will demonstrate how to utilize a distributed queue within a group of AMQ brokers.                   Table Of Contents 1. Introduction 2. Apache ActiveMQ Server Installation 3. Producer Java Application 3.1. MessageProducerApp ...

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 Swing GridLayout Example

In Swing, in order to arrange components in a form, dialog box etc. in user friendly manner layout manager is found to be very useful. There are several layout managers. GridLayout is such layout manager. 1. Introduction GridLayout actually forms a grid like arrangement of cells. This is just like one excel spreadsheet where each cell is of same size. If ...

Read More »

Java UUID Generator Example

Hello readers, in this tutorial, we are generating the UUID using the Java and Java UUID Generator API. 1. Introduction UUID / GUID (Universally / Globally Unique Identifier) is frequently used in programming. Some of its usages are for creating random file names, session id in the web application, transaction id and for record’s primary keys in the database (i.e. ...

Read More »