Create and Use Maps with mapOf and mutableMapOf in Kotlin
📖 Scenario: You are organizing a small library. You want to keep track of book titles and their authors using a map.
🎯 Goal: Build a Kotlin program that creates a map of books and authors, adds a new book, and then prints all entries.
📋 What You'll Learn
Create an immutable map using
mapOf with given book-author pairsCreate a mutable map using
mutableMapOf from the immutable mapAdd a new book and author to the mutable map
Print all book titles and authors from the mutable map
💡 Why This Matters
🌍 Real World
Maps are useful to store pairs of related data, like book titles and authors, product names and prices, or usernames and emails.
💼 Career
Understanding how to create and manipulate maps is important for many programming jobs, especially when working with data collections and key-value pairs.
Progress0 / 4 steps