A data class is a class that mostly serves as a container for some data, represented by properties in the constructor.

Kotlin automatically generates a lot of methods for a data class, including:

  • a toString() method that shows all of the constructor properties

  • an equals() method that uses the constructor properties to determine if two instances of the class are equal

  • a copy() method that makes it easy to create a new instance of the class by copying the values of another instance and overriding them selectively

You can learn more about this in:
Run Edit