Anand Sunderraman
Anand Sunderraman

Reputation: 8138

Hash Map Usage and Idea

I have been working in Java for the last 6 months and have been using Hash Maps

What is the basic idea of a Hash Map ? I am using it as it easy for me to store so much data with direct key references rather than having to iterate through an arraylist ?

Where is the power of Hash Map seen ? What is the scientific idea behind this data structure ?

Upvotes: 0

Views: 855

Answers (2)

navr
navr

Reputation: 72

Hashmap works on Key/Value based architecture. Duplicate keys are not allowed. Hashmap uses hashcode to store/retrieve values from the bucket. The purpose of ArrayList is different. It is just a list of items/objects. You have to use index (int) to retrieve an item from ArrayList. Hashmaps are even more powerful. It allows any Object to be used as a key.

This link should help you to understand things better: http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashMap.html

Upvotes: 0

Adamski
Adamski

Reputation: 54715

This Wikipedia article on Hash Tables should be able to help you. In particular check out the Uses section.

Upvotes: 1

Related Questions