public void addItem(String itemName,int numItemAdd) {
HashMap <String,Integer> items = new HashMap<String,Integer>();
int totalval;
totalval =+ numItemAdd;
items.put(itemName,totalval);
}
I am new to HashMaps. I am wanting to add the integers to the specific itemName. For example, addItem("socks",100); addItem("socks",200). Whenever I do this, instead of getting 300 I only get 200. I know that put() replaces the last value used, but I do not know how to add the numbers so that I can get 300 instead of having the last value used.