I have a Map<Character, String>
that already gets a value for the key (Character) based on a for loop. How can I now go through this map and check whether a certain key is in this map (e.g. 'A' or 'a' [because case ignore]) and then add my desired value (e.g. 4) to this key (so that from "A=" becomes an "A=4")?
I hope my problem is clear
Here is my present code:
public static Map<Character, String> replacings(String s) {
Map<Character, String> leetMap = new TreeMap<>();
for(int i = 1; i < s.length(); i++) {
if(s.charAt(i) == '=') {
leetMap.put(s.charAt(i - 1), "");
leetMap.put(s.toLowerCase().charAt(i - 1), "");
}
}
for(int j = 0; j < leetMap.size(); j++) {
//look for the key here and then add a value to it [my problem]
}
return leetMap;
}
My main method until yet (example):
Map<Character, String> mappings = replacings(
"A=4,B=8,E=3,G=6,L=1,O=0,S=5,T=7,Z=2,"
);
So now, I want to add the numbers to the keys.