How to replace a string to a set of one characters

  • A+

How do I replace an inputted string word to a set of one character: For example:

The string is: Hello Word The output should be: aaaaa aaaa

The space should remain a space.

I've tried this one but there's no space.

Scanner input = new Scanner(; String word =  input.nextLine();  for(int i = 0; i < word.length(); i++){                      System.out.print("a"); } 



System.out.println("Hello Word".replaceAll("//S", "a")); 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: