Milo Chang
Avanish Gupta
Milo Chang
Avanish Gupta
hashCode()
equals()
toString()
hashCode()
hashCode()
method returns what is known as a hash code, an integer that is used to represent the memory location of the object. This is usually based on the properties of an object and any two objects with the same properties should have the same hash code.equals()
equals()
method that we first learned about in Unit 3. This method determines whether two objects are equal to each other based on whether they have the same properties or not. If two objects are determined to be equal, then they must have the same hash code.toString()
toString()
method from Unit 5. This method returns a string representation of the object that the method is called on. This usually prints the properties of the object, but by default, the method returns objectName + "@" + hashCode()
, which in most situations, does not give any useful information about an object.© 2024 Fiveable Inc. All rights reserved.