java change hashmap value code example
Example 1: change dictionary value python
my_dict = {
'foo': 42,
'bar': 12.5
}
my_dict['foo'] = "Hello"
print(my_dict['foo'])
'Hello'
Example 2: java hashmap get value
package com.tutorialspoint;
import java.util.*;
public class HashMapDemo {
public static void main(String args[]) {
// create hash map
HashMap newmap = new HashMap();
// populate hash map
newmap.put(1, "tutorials");
newmap.put(2, "point");
newmap.put(3, "is best");
// get value of key 3
String val = (String)newmap.get(3);
// check the value
System.out.println("Value for key 3 is: " + val);
}
}
Example 3: java hashmap set value
myMap.put(key, value);