Q:

How can I change the value of a key in a hash map?

I have created a hash map that the users input the key and the value. I want to be able to change the value of the hash map if a specific key is entered. I tried the setValue method but got nothing. The value and the key are both strings. What method would I use to change this?

A:

Just use Map#put using the current old key and the new value:
Map<String, String> map = new HashMap<>();
map.put("user", "Luiggi Mendoza");
System.out.println(map);
//replacing the old value
map.put("user", "Oli Charlesworth");
System.out.println(map);

Output:
{user=Luiggi Mendoza}
{user=Oli Charlesworth}

