What is the use of Hashmap in java?? | SoloLearn: Learn to code for FREE!

+3

What is the use of Hashmap in java??

Hashmap

1/31/2019 2:31:31 PM

Sanaya

4 Answers

New Answer

0

In a HashMap you can store data collections. You store a pair (key, value). For example you want a list of persons and their jobs. Person --> key Job --> value "John Doe"; "Teacher" "Jane Doe"; "Programmer" ... Hashmap: [John Doe = Teacher, Jane Doe = Programmer] The special thing is that you can not use a key more than one time. Adding a key that already exists, overwrites the old element. In the challenge adjacent clone letters I used a Hashmap for the letters (key) and the number of clones (values). Because I wanted the connection between the letter and their clones. And I didn't want duplicates. https://code.sololearn.com/cy5oNTefTXIb/?ref=app

+2

Thank you

0

You can also look here: https://www.sololearn.com/learn/Java/2181/?ref=app

0

How do you format it correctly? I've been searching for this function similar to a dictionary in python. Can you assign the same name to a key and value such as "Apple"; "Apple" ?