如何将"./"替换为""?我试过了:
String s = "./";
s.replaceAll("\\./","");
Run Code Online (Sandbox Code Playgroud)
为什么以上的工作对我不起作用?
String
实例在Java中是不可变的,因此s.replaceAll()
不会修改s
但会返回String
带有所请求更改的new :
String s = "./";
String s_modified = s.replaceAll("\\./", "");
Run Code Online (Sandbox Code Playgroud)