equals() and hashCode() contracts or whatever

The equals and hashCode methods are closely related to each other, and it's a good idea to override both methods in a consistent way. Plenty of people know this. But not everyone fully understands the reason for this rule and the consequences for breaking it.

In this post, we'll take a look at the idea behind these methods, review their purpose, and explore why they're so related.

Immutability in Java: final, constants and immutable

In this lesson, we will talk about the special final modifier. You can think of it as a way to "freeze" parts of our program where we need constant, unambiguous, and unchanging behavior.

We can apply it to three elements of our program: classes, methods, and variables. Let's go over them in turn.

Video: Java. Object class Survey of interview questions

What is the finalize method for? What are the specific features of the wait, notify, and notifyAll methods? How are the equals and hashCode methods related? Why do all Java classes inherit Object? The video provides answers to these and many other questions.