I am trying to go through an array of characters and replace that character in the string with the parallel character in the other array.
private String replace(String input)
{
char[] first = {'a','e','o','s'};
char[] second = {'@','3','0','$'};
String myCopy = input.toLowerCase();
for(int y = 0; y < first.length; y++)
{
myCopy.replace(first[y],second[y]);
}
return myCopy;
}
Here's and example of what I get:
Enter a string: as the dog runs here
Output: as the dog runs here
It always outputs the same string with no replacements.
I also tried using:
myCopy.replace('a','@');
and
myCopy.replace("a","@");
and the replaceAll method.
Any suggestions?