是的,replaceAll 方法支持鏈式調用??梢赃B續調用多個 replaceAll 方法來對字符串進行多次替換操作。例如:
replaceAll
String str = "Hello world!"; String newStr = str.replaceAll("Hello", "Hi").replaceAll("world", "Universe"); System.out.println(newStr); // Output: Hi Universe!