To compare two objects in a class write an equals method that will make a field by field compare of the two objects.
When two strings are compared using the equals() method, true is returned if they are equal and false otherwise. The String equals() function in Java compares two strings based on their data/content. It returns true if all of the contents of both strings match. It returns false if none of the characters match. The two key methods offered by the Object class for comparing objects are equals() and hashcode(). All Java objects inherit the default implementation of these two methods because the Object class is the parent class for all Java objects.
Hence, To compare two objects in a class write an equals method that will make a field by field compare of the two objects.
To learn more about the equals method click,
https://brainly.com/question/12905686
#SPJ4