V
Vinsoft Lab
Learn • Build • Grow
Mobile Development Intermediate Paid

Kotlin Mobile Development

Learn Kotlin from the fundamentals to object-oriented programming, collections, null safety, functions and Android development foundations.

10 Weeks 24 Lessons Android Development Foundation
Your Progress 0%
LESSON 21

Data Classes

Learn how data classes simplify classes designed mainly for holding information.

Kotlin Code

Study the example and understand each part.

KOTLIN
data class Student(
    val name: String,
    val age: Int,
    val grade: String
)


fun main() {

    val student =
        Student(
            "Mary",
            17,
            "A"
        )

    println(student)

}

Kotlin is commonly developed using Android Studio or IntelliJ IDEA. These examples can be used as a foundation for Android application development.

Key Concept

Data classes are designed for holding data and automatically provide useful methods such as toString(), equals() and copy().

Expected Output / Result

Student(name=Mary, age=17, grade=A)

Finished this lesson?

Mark it complete to update your course progress.

Quick Knowledge Check

Test your Kotlin understanding.

Which keyword creates a read-only variable in Kotlin?

Vinsoft Lab Academy

Learn Kotlin. Build Android applications.

Build a strong Kotlin foundation and continue into practical Android application development.