Documente Academic
Documente Profesional
Documente Cultură
2
Get a String from our Detective
3
equals and toString
□ toString()
– Returns a String representation of the object
– Default: ClassName@HashCode, e.g.: Detective@70dea4e
– Return value should be individualized to the respective class
4
toString Code Example
6
equals and toString
□ toString()
– Returns a String representation of the object
– Default: ClassName@HashCode
– Return value should be individualized to the respective class
□ equals(Object obj)
– Compares two objects
– Default: Compares the memory addresses of the objects
– Should be overriden for own classes to test specific attributes
7
equals Code Example
false
true
10
Class Object
Christiane, Ralf, Ann, Tom