Core Java

Java 8 Streams findFirst() vs findAny()

Introduction: Java 8 Stream API has two methods – findFirst() and findAny() which often seem confusing at first. In this article, we’ll learn the differences between the two so that we can choose wisely the next time. Stream.findAny(): findAny() method is a short-circuiting terminal operation. It returns an Optional<E> describing some element of the stream […]

Be the First to comment. Read More
Core Java

Java 8 Stream sorted()

Introduction: Java 8 Stream API is a powerful way to achieve functional programming. In this post, we’ll learn about Java 8 Stream sorted() method by looking at some good examples. In case you wish to learn more about Java 8 Streams API in general, we’ll suggest you read this article. Signature: There are two variants […]

Be the First to comment. Read More
Core Java

Factory Object Pattern In Java

Introduction: A Factory Object Pattern comes into picture when having a parent-child class relationship or having an interface based implementation. As the name suggest, the idea is to create a factory class which will be responsible for conditionally instantiating one among the several defined object types. It promotes loose-coupling by delegating the overhead of instantiating […]

One comment Read More
Core Java

Singleton Design Pattern In Java

Introduction: Singleton Design Pattern is one of the basic and most useful Design Patterns in Java. It comes under the category of the creational pattern as defined in Gang of Four Design Patterns. The central idea behind this design pattern is to ensure that only a single instance of a class is created in the […]

Be the First to comment. Read More
Core Java

HashMap vs HashTable In Java

Introduction: Both HashMap and HashTable implements java.util.Map interface and are used to store key-value pairs but there are some important differences between them. In this tutorial, we’ll cover the differences between HashMap and HashTable. Similarities Between HashMap and HashTable: Before we cover the differences, let’s look first at the similarities between a HashMap and a […]

Be the First to comment. Read More
Core Java

Java : Pass By Value Or Pass By Reference

Introduction: Java is Pass By Value or Reference is often a debated question among many Java developers. The answer to it is that Java is a Pass By Value, not Pass By Reference. In this tutorial, we’ll see how. To follow along with this tutorial, let’s first understand these two terms: Pass By Value: The […]

Be the First to comment. Read More
Core Java

Java 8 Stream Collectors

Introduction: Java 8 Streams is a powerful feature introduced in Java 8. To learn more about Streams in Java, we’ll suggest you read this post. In this tutorial, we’ll cover how to collect the output stream into one of the known Collection types followed by exploring a few other Collectors options. We’ll be reusing the […]

Be the First to comment. Read More
Spring

Spring Http Request Logging

Introduction: Logging the Http requests in a web application is a very common requirement. In this tutorial, we’ll learn to log all our incoming Http requests in Spring framework. To follow along with the tutorial, we assume that the reader has an understanding of spring-core and Logback. Using CommonsRequestLoggingFilter: A pretty simple way to log […]

Be the First to comment. Read More
Core Java

Introduction to Java 8 Stream API

Introduction: Java 8 introduced functional programming and the concept of streams and functional interfaces to back it. As the name suggests, Java 8 Stream can be thought of as a stream or source of data to operate on. For this tutorial, we assume the reader to have an understanding of Java Optional and Functional Interface. […]

Be the First to comment. Read More
Core Java

Remove All Occurrences Of Newline From byte Array

Introduction: In this article, we’ll uncover ways in which we can remove all line breaks or newline characters from a byte array in Java. For this tutorial, we are assuming line breaks for our system would mean “\n” character(usually true for a Unix environment). Removing Line-Breaks from byte Array: 1. Using java.lang.String: An easy implementation […]

Be the First to comment. Read More