Stage 1 · Lesson 4 of 9
Classes and data classes
A class lists its properties right in the : class User(val id: String, val name: String). Classes are final unless you mark them open, which means other classes cannot extend them by default. Properties replace the getter and setter methods you may know from .
For models, use a . It writes equals, hashCode, toString, copy and destructuring for you, all from the constructor properties. copy changes one field and keeps the rest, as in user.copy(name = "Ana").
That is how you update UI state without changing the original. Use object when you want exactly one instance, and companion object for factory functions.
Common trapa data class with var properties shared between screens, which can change without anything noticing.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- GuideFreeKotlin Documentation
JetBrains
Start with the Kotlin tour, then the null safety and coroutines basics pages
- CourseFreeAndroid Basics with Compose
Google · Beginner
The Kotlin pathways in Units 1 to 3 teach the language with practice sets