Woohoo! Excellent work. You’ve completed the final lesson on collection types in Kotlin. Let’s review what was covered:

  • A map is a collection that stores key-value pairs of data.
  • The keys within a map must be unique, however, the values can duplicate.
  • An immutable map is declared with the mapOf keyword and indicates a map whose entries cannot change throughout a program.
  • A mutable map is declared with the mutableMapOf keyword and indicates a Map whose entries can be altered.
  • Values within a map can be accessed using shorthand [key] syntax.
  • To return all the values in a map, use the values property. To return all the keys in a map, use the keys property.
  • The put() function accepts a key and a value to add to a map.
  • The remove() function accepts a key and removes the entry associated with that key.

You’ve now covered the third and final major collection that exists in Kotlin. Feel free to utilize the empty Review.kt file and output terminal on the right to hone your understanding of maps and practice writing Kotlin code.


Click Up Next when you’ve completed the review and are ready to move on.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?