🪴 Nishanth Gobi

Data Classes in Kotlin

Apr 23, 20241 min read

  • zettel
  • lit
  • kotlin
  • Data classes have the same functionality as classes, but they come automatically with additional member functions
  • Some useful pre-defined member functions,
    • toString()
    • equals() or ==
    • copy()
data class User (
	val name: String,
	val id: Int
)

Refs

  1. https://kotlinlang.org/docs/kotlin-tour-classes.html#data-classes

Graph View

Created with Quartz v4.5.2 © 2026

  • GitHub
  • X
  • LinkedIn