文字の配列を調べ、文字列のその文字を他の配列の平行文字に置き換えようとしています。文字列内の文字を置き換えることができません
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;
}
ここだと私は何を得るの例:
Enter a string: as the dog runs here
Output: as the dog runs here
それは常に無交換と同じ文字列を出力します。
私も使用してみました:
myCopy.replace('a','@');
and
myCopy.replace("a","@");
とでReplaceAll方法。
提案がありますか?
ありがとうございます。だからシンプルな私はそれを実現しませんでした。 –