juniorKotlin
What is a data class?
Updated May 16, 2026
Short answer
A data class holds data and auto-generates methods.
Deep explanation
It automatically creates equals, hashCode, toString, and copy methods.
Real-world example
Used for API response models.
Common mistakes
- Using regular class instead of data class.
Follow-up questions
- Can data classes be inherited?
- What is copy function?