Skip to Main Content
Hands-On Data Structures and Algorithms with Kotlin
book

Hands-On Data Structures and Algorithms with Kotlin

by Chandra Sekhar Nayak, Rivu Chakraborty
February 2019
Intermediate to advanced content levelIntermediate to advanced
220 pages
5h 40m
English
Packt Publishing
Content preview from Hands-On Data Structures and Algorithms with Kotlin

Maps – working with key-value pairs

The Map interface is a bit different than all the other interfaces in the collections framework, such as Set or List. Unlike them, it works with key-value pairs. If you're thinking of Pair, then let me say no, this is not similar to Pair. A Pair is just a pair of two values combined together while a Map is a collection of key-value pairs.

In a Map, keys are unique and cannot be duplicated, whereas values can be redundant. If you try to add two values with the same key, then the latter one will replace the previous one. Values, on the other hand, can be redundant/duplicate. The main reason behind this behavior is that in Map, items are not stored  based on order or anything else, but rather a value is stored ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Data Structures and Algorithms with Golang

Learn Data Structures and Algorithms with Golang

Bhagvan Kommadi
Functional Programming in Kotlin

Functional Programming in Kotlin

Runar Bjarnason, Paul Chiusano, Marco Vermeulen

Publisher Resources

ISBN: 9781788994019Supplemental Content