String Representation and Objects Equality

Explore how Kotlin’s toString method works, both by default and with data classes. Understand the concept of object equality using the equals method.

Transforming to a string

The default toString transformation produces a string that starts with the class name, then the @ sign, and then the unsigned hexadecimal representation of the hash code of the object. The purpose of this is to display the class name and to determine whether two strings represent the same object or not.

Get hands-on with 1400+ tech skills courses.