


So I don't actually need to say too much more about them. But generally you can think of a list in Kotlin, you can work with it in pretty much the same way as you would do in Java.

We can look through them, and we're going to talk a bit more about special things we can do with the lists when we get to the chapter on functional programming. And we can pass an immutable list from Kotlin to it. In Kotlin, mutableListOf () method is used to instantiate MutableList Interface. Now, the way we work with lists in Kotlin, we've already seen a little bit. We can imagine it does some string processing or validation and then it appends an item to the list. That will create for us an empty, mutable list, but we can supply integers into that list. In other words, if we had a mutable list of numbers and I didn't want to provide any initial values, we'd say mutable list of, but I'd put in here in angle brackets int, for example, and leave my brackets empty. When we use mutable list of, we don't have to provide initial values, but if we don't, then we must provide the data type in the form of a generic class. The const modifier in Kotlin is used for compile-time constants. Well, let's go for Monday, Tuesday, and Wednesday. Well, rather than using list of, we can say mutable list of and provide the values. Let's create a list called days, and I want this one to be a mutable list. If we want to create a mutable list, well, we can do that, as we've already seen, by creating a new array list, but there's also a more Kotlin-like syntax that we can use.
