Mutable lists

In this section, we will discuss mutable lists in Kotlin. These lists are not write-protected, which means that we can add new elements, update existing ones, and remove any element from the list. Just like immutable lists, Kotlin provides dedicated interfaces and iterators for mutable lists, which contain useful sets of functions. Let's see how we can create a mutable list:

val list = mutableListOf(1,2,3,4,5)

The mutableListOf keyword is used to declare and initialize a list. The size of the list depends on the number of values, and the type of the list depends on the type of the value. Let's explore the interfaces of the mutable list and discuss all of the functions and iterators step by step.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.15.161