Mutable Lists
Learn how mutable lists allow applications to add, remove and modify data.
Kotlin Code
Study the example and understand each part.
fun main() {
val students = mutableListOf(
"Brian",
"Mary"
)
students.add("John")
students.add("Amina")
students.remove("Mary")
for (student in students) {
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
A mutableListOf() allows items to be added or removed after the list has been created.
Expected Output / Result
Brian John Amina
Finished this lesson?
Mark it complete to update your course progress.