I created a hash map in which users enter the key and value. I want to be able to change the value of the hash map if a certain key is entered. I tried the setValue method but received nothing. The value and key are strings. What method would I use to change this?
setValue
Just use Map#put using the current old key and the new value:
Map#put
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);
Conclusion:
{user=Luiggi Mendoza} {user=Oli Charlesworth}
Source: https://habr.com/ru/post/1200165/More articles:When is everything alright with a JavaScript namespace alias, type or method? - javascriptHow to get shape geometry type in PyQgis - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1200162/how-to-answer-a-request-but-continue-processing-code-in-webapi&usg=ALkJrhhyETvqW3zWt_piuoQKNQzxDiY5Kgcomputing backward descents of permutations - c ++String to Long compares throws "ELException: Can not convert" in Tomcat 7, works in Tomcat 6 - jspRefresh the view of parent activity before moving on to it - androidHow to link binaries between docker containers - dockerIt is impossible to determine the main end of the relationship when saving an order - EF6 - c #Forcing inline tweet to 100% width - javascriptContentControls that reference the same StaticResource display only one resource - wpfAll Articles