How to edit a java map
I have a simple question about a java map.Suppose I have a map that has a key and value already set. How do I change the value开发者_运维技巧 of that key; what method would I use?
Just call a normal put -- it will replace the existing value for the key. If you need to access the old value for that key, the put method returns it.
See the javadoc for more details.
I suppose you're referring to the java.util.Map
class? You can simply use put()
- it will replace an existing value if that key has already been set.
精彩评论