Data classes are classes specifically designed to hold data. The compiler automatically generates equals(), hashCode(), toString(), copy(), and destructuring declarations.
data class Person(val name: String, val age: Int)
val person1 = Person("Alice", 30)
val person2 = person1.copy(age = 31) // Copy with modification
val (name, age) = person1 // Destructuring
println(person1) // Automatically generated toString()
Requirements for data classes:
Primary constructor must have at least one parameter
All parameters must be marked as val or var
Cannot be abstract, open, sealed, or inner
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.