‫Now open Android Studio, create a new project or remove all the classes and files of the previous sections.
‫Create a new Kotlin file and this file.
‫I'll name it as Hello collections, and I'll start with the function main.
‫In order to allow Android Studio to run this file, a list in general is an ordered collection in which
‫we can access elements by using indices that define a position for each element.
‫We have two types of lists, immutable and mutable.
‫I'll start with the immutable.
‫An immutable list in Kotlin is a read only collection of elements that cannot be modified once it's
‫created.
‫You can use it when you want to ensure that the list's contents remain unchanged after initialization.
‫Immutable lists are created using the list of or list of not null functions, as in Kotlin's standard
‫library.
‫I'll start by creating a val fruits equals to list of and.
‫This is the function that it is used to create an immutable list.
‫In Kotlin, this function takes a var arg variable length argument parameter, allowing you to specify
‫the elements you want to include in the list.
‫Here you can specify the generic type of this list, or whenever you create elements, it will detect
‫the type of this list so you can get rid of this generic type.
‫I'll start with the first element which is the apple, banana, cherry, and so on.
‫These are three elements of my immutable fruits list.
‫The fruits list is immutable.
‫You can't add or remove or modify elements in it after creation.
‫If I try to access the fruits dot and add function, there are no add, remove or modify functions in
‫the fruits.
‫Immutable list.
‫This immutable list contains a specified fruits in the order they are provided.
‫You can access elements of an immutable list by their index, iterate over the list, or perform various
‫read only operations on it.
‫For example, if I need to print all the lists, I can use the for loop and I create an item in fruits.
‫So every item in the list called fruits go and print this item.
‫Run the program.
‫And here we go.
‫We printed all the elements of this immutable list.
‫This immutability ensures that the list content remain constant through the list lifetime.
‫Keep in mind that if you need to modify a list, you should use mutable lists created with mutable list
‫of function, which allows you to add, remove and modify elements.