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

Anonymous Classes in Java 1. Introduction In this tutorial, we’ll consider anonymous classes in Java. We’ll describe how we can declare and create instances of them. We’ll also briefly discuss their properties and limitations. 2. Anonymous Class Declaration Anonymous classes are inner classes with no name. Since they have no… Continue Reading java-anonymous-classes