线
System.out.println("\\");
打印一个反斜杠 ( \)。和
System.out.println("\\\\");
打印双反斜杠 ( \\)。明白了!
但是为什么在下面的代码中:
class ReplaceTest
{
public static void main(String[] args)
{
String s = "hello.world";
s = s.replaceAll("\\.", "\\\\");
System.out.println(s);
}
}
是输出:
hello\world
代替
hello\\world
毕竟,该replaceAll()方法是将点 ( \\.) 替换为 ( \\\\)。
有人可以解释一下吗?