Variables with val and var
Learn the difference between immutable val variables and mutable var variables.
Kotlin Code
Study the example and understand each part.
fun main() {
val school = "Vinsoft Lab"
var students = 50
students = 75
println(school)
println(students)
}
Kotlin is commonly developed using Android Studio or IntelliJ IDEA. These examples can be used as a foundation for Android application development.
Key Concept
Use val when a reference should not be reassigned and var when its value needs to change.
Expected Output / Result
Vinsoft Lab 75
Finished this lesson?
Mark it complete to update your course progress.