Val for immutable references
📖 Scenario: Imagine you are creating a simple program to store information about a book. You want to make sure that the book's title does not change once it is set.
🎯 Goal: Learn how to use val in Kotlin to create an immutable reference for a variable.
📋 What You'll Learn
Create a variable using
val to hold a book titleAssign the exact string
"Kotlin Basics" to the variableTry to change the value of the variable (this will be explained)
Print the value of the variable
💡 Why This Matters
🌍 Real World
In real apps, using <code>val</code> helps keep important data safe and predictable, like user names or IDs that should not change.
💼 Career
Understanding <code>val</code> is essential for Kotlin developers to write reliable and bug-free code.
Progress0 / 4 steps