-2

I am working on a project where I take a user-inputted String and replace "and" with "&", "for" with '4', etc. and then prints out the modified String. How would I be able to do this?

PS: I know there's a replaceAll() function but that only works for characters, right? Is there any way I could use this in my code?

Thank you in advance!

galanova
  • 1
  • 2

1 Answers1

1

If you really want to chang the string into chsr first then You can use the String's method called toCharArray() which converts the string into array of characters.

String sWord hello;

char[] cArray;

cArray = sWord.toCharArray()

Then just use a combination of for loops and if-statements to replace the characters you need

Community
  • 1
  • 1