# Notes of a Web Developer Learning Kotlin and Android Development - part 2

DevFeed: [Notes of a Web Developer Learning Kotlin and Android Development - part 2](<https://devfeed.tech/articles/notes-of-a-web-developer-learning-kotlin-and-android-development-part-2-38450.md>)

Original publisher: [Read original article](<https://eevis.codes/blog/2022-08-18/notes-of-a-web-developer-learning-kotlin-and-android-development-part-2/>)

Author: Eevis Panula

Published: 2023-09-04T03:34:20.323000Z

Content type: article

Language: en

Sources: [Eevis Blog](<https://devfeed.tech/sources/eevis-blog.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [android-development](<https://devfeed.tech/topics/android-development.md>), [Development](<https://devfeed.tech/topics/development.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [code](<https://devfeed.tech/tags/code.md>), [developer](<https://devfeed.tech/tags/developer.md>), [development](<https://devfeed.tech/tags/development.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [sorting](<https://devfeed.tech/tags/sorting.md>), [syntax](<https://devfeed.tech/tags/syntax.md>)

## AI overview

A web developer documents the second unit of the Android Basics in Kotlin course, covering Kotlin lists, list operations, loops, and syntax, along with Android layouts and adapters.

## Source excerpt

This blog post is the second in a series of posts about me working through the Android Basics on Kotlin-course. You can find the first one here: Notes of a Web Developer Learning Kotlin and Android Development - part 1 The second unit of the course, "Android Basics in Kotlin," is about Layouts. It also goes through some Kotlin-concepts, such as lists and with-syntax. From the Android side, the most significant theme is layouts, particularly adapters. Kotlin: Lists and Other Things Lists There are different list types in Kotlin. Lists can be either mutable or immutable - you need to decide which one when defining the list. That's different from JavaScript: Even though you define them as constant in JS, you can still add and remove things. In Kotlin, you need to have a mutable list to do that. Lists are defined with the following syntaxes: val immutableList = listOf("list", "of", "words") val mutableList = mutableListOf("other", "words") Printing these would result in [list, of, words] and [other, words] You can get the first item from a list with method first() and the last item with method last(). Sorting a list happens with the sorted()-method, and you can reverse a list with reversed(). Mutable lists have a set of additional methods to mutate the list; here are some examples: add() Add an item to the list. addAll() Add a collection to the list. More about other collection types in the next part. remove() Remove an item from the list. clear() Clear the list. isEmpty() Check if the list is empty. Again, here's plenty more than what you'll have with JavaScript. I mean, you can do all of these with JS, but you need to write more code for that, and it's not as verbose. Let's take a look at checking if a list is empty. With Kotlin, it would be: // Kotlin val list = listOf(...) val isListEmpty = list.isEmpty() And with JavaScript: // JavaScript const list = [...] const isListEmpty = list.length === 0 // or const isListEmptyShorter = !list.length A final thing about the l