-1
I’m not able to replace all the letters of the word with an asterisk, only a few are being replaced. How do I get them all replaced?
Scanner sc = new Scanner(System.in);
String conversor = null;
System.out.println("Digite a palavra a ser criptografada");
String palavra = sc.nextLine();
for(int i=0;i<palavra.length();i++){
conversor = palavra.replace(palavra.substring(i), "*");
System.out.println(conversor);
}
System.out.println(conversor);
sc.close();
Do you have to print all these times? Why? Or if you did it to verify the steps and only need the printed asterisks at the end in place of the typed text? And why do you need this? Seems like something meaningless or something too simple to even curl up, is there anything we don’t know about the problem? Any requirement not shown in the question?
– Maniero
I put it out to print every time just to find out what was going on inside the for. I’m training in cryptography and they passed me this exercise.
– Fabio Rodrigues
I want the entire String to have an asterisk. Encrypted Word = ****** ************
– Fabio Rodrigues