How to print all the values for a key in HashMap in java -


map<string, string> map = new hashmap<string, string>(); map.put("1", "xyz"); map.put("1", "abc"); map.put("1", "cde"); map.put("2", "err");` 

`

for above map want values associated key 1. expected output.

key:: 1 values are:: xyz, abc, cde

order of values doesn't important.

in map key should unique. if associate new value existing key, overwrite value of existing entry.

you might need check interface map#put(k, v) method.

if map contained mapping key, old value replaced specified value.

so in case map have "cde" value key "1".


Comments

Popular posts from this blog

How to logout from a login page in asp.net -

Stack level too deep error after upgrade to rails 3.2 and ruby 1.9.3 -