How to update a String value in a map?
I have a treeMap that maps a string to a string
TreeMap<String, String> dictionary = new TreeMap<String, String>();
I also have an arrayList of strings that need to be iterated through and every term has to be placed inside the treemap mapping to a string "p" if it doesn't exist in there already, and if it does I need to replace the previous value by concatenating another "p" to the old one,
so if a particular string appears in the arraylist 3 times, its will map to the value "ppp".
I know for integer values you can use a intValue() but I can't find something I can use similar to that.
String val = ((String) dictionary.get(terms.get(j)[k])). -I don't know what to put here - ();
dictionary.put(terms.get(j)[k], new String(val.concat("p"));
Is there some method I can use to obtain the old string value and then change it?
Re: How to update a String value in a map?
I'm not sure what you are asking...the Map should return the string when you call get(), then you can concatenate the next string on it and call put to replace the previous.