public class Test1 {
public static void main(String[] args) {
    String s = "ciao";
    String underscore = s.replaceAll(".", "_ ").trim();
    if (s.contains("a")){
        for (int i = 0; i< underscore.length(); i++){
        }
    }
    System.out.println(underscore);
}
}
Hello how to replace the string "a" in the correct posistion of the underscore? I am doing an HangMan game so the algorithm that I have to implement is general not only this case. The problem is that my index of underscore are different and the format is "_ _ _ _" have to be "c i a o" but if I do only one guess so "a".. the output is " _ _ a _"
 
     
     
    