Am trying to gives more than one value to a key in a map. I wanted something of this kind to work..
mapp.put(“key1″,”value1”)
mapp.put(“key1″,”value2”).
The first value “value1” is getting over-ridden with “value2”. How to retain both the values? Should I go for any other thing than maps for this to happen?
Am trying to gives more than one value to a key in a map.
Share
You can use un map with list. Something like that:
For put a
key1with the first value:For add the second value to
key1You can have all this in one method
If you want the values for the
key1, you obtain aList