Java equals() and hashCode() Contracts 1. Overview In this tutorial, we’ll introduce two methods that closely belong together: equals() and hashCode(). We’ll focus on their relationship with each other, how to correctly override them, and why we should override both or neither. 2. equals() The Object class defines both the… Continue Reading java-equals-hashcode-contracts

How to Disable Console Logging in Spring Boot 1. Overview Usually, console logs give us the opportunity to debug our system in an easy and intuitive way. Nevertheless, there are occasions when we don’t want to enable this feature in our system. In this quick tutorial, we’ll see how to… Continue Reading spring-boot-disable-console-logging

Spring 5 Functional Bean Registration 1. Overview Spring 5 comes with support for functional bean registration in the application context. Simply put, this can be done through overloaded versions of a new registerBean() method defined in the GenericApplicationContext class. Let’s have a look at a few examples of this functionality… Continue Reading spring-5-functional-beans

java.util.Date vs java.sql.Date ** 1. Overview In this tutorial, we’re going to compare two date classes: java.util.Date and java.sql.Date. Once we complete the comparison, it should be clear which one to use and why. 2. java.util.Date The java.util.Date class represents a particular moment in time, with millisecond precision since the 1st of… Continue Reading java-util-date-sql-date

Implementing a Runnable vs Extending a Thread 1. Introduction “Should I implement a Runnable or extend the Thread class”? is quite a common question. In this article, we’ll see which approach makes more sense in practice and why. 2. Using Thread Let’s first define a SimpleThread class that extends Thread:… Continue Reading java-runnable-vs-extending-thread