Javaで文字列を置換するには、replaceAll(リプレースオール)()メソッドを使用する。
replaceAll("検索文字列",''置換文字列")のように使う。
「おはようございます」の「おはよう」を「ohayou」に置換した例。
public class Mozitikan {
public static void main(String[] args) {
String aisatu = "おはようございます";
name = aisatu.replaceAll("おはよう","ohayou");
System.out.println(aisatu);
}
}