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

HTTP/1.0 407 Proxy Authentication Required PHP -

curl - PHP fsockopen help required -

c# - Resource not found error -