Comparing Objects and Private Methods

This code illustrates the two different ways of comparing objects: using == or using the equals() method. The == operator tests for memory equality. The equals() method tests for state equality.

Private methods help keep your code organized, concise, and cut down on errors caused by copying-and-pasting code. Anytime you find yourself typing the same code, again and again, you should stop and write a private method instead!