hashMap data retrive
1 Answer
hashMap data retrive
| Flag | PURGE
i had declared hashMap object and put two values with the same key.
e.g
hm.put("key1","abc");
hm.put("key1","xyz");
when i retrieve the value of hashMap by the key "key1" i got value "xyz" because it override the value of "key1".
but if i want to retrieve the old value "abc" then how it possible. please solve my doubt .
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
First make sure what you want beacause hashMap is designed such that it will give overrride latest value. If u want to get only first value, then map should be designed such that it will allow first entry with same key. And if you want all the values, make the value of hashMap a List.
- HardCoder July 19, 2014