0
I am not able to alter the character of my string with that of the map value, if they are equal: key and character.
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class Mapa {
public static Map<Character, Character> mapa;
public static void main(String[] args) {
mapa = new HashMap<>();
mapa.put('á', 'a');
mapa.put('é', 'e');
mapa.put('í', 'i');
mapa.put('ó', 'o');
mapa.put('ú', 'u');
String str = "cása";
for(int i=0; i < str.length(); i++) {
Character ch = str.charAt(i);
for(Entry<Character, Character> entry : mapa.entrySet()) {
if(ch == entry.getKey()) {
str = str.replace(ch, entry.getValue());
}
}
}
// Aqui esta retornando a mesma string.
System.out.println(str);
}
}