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 19

Constructors and Properties

Learn how Kotlin constructors and properties make class creation shorter and cleaner.

Kotlin Code

Study the example and understand each part.

KOTLIN
class Product(
    val name: String,
    var price: Double
) {

    fun display() {

        println("Product: $name")
        println("Price: $price")

    }

}


fun main() {

    val product =
        Product("Laptop", 55000.0)

    product.display()

}

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

Key Concept

Kotlin's primary constructor allows properties to be declared directly in the class header.

Expected Output / Result

Product: Laptop
Price: 55000.0

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.