The line
System.out.println("");
prints a single back-slash (
). And
System.out.println("");
prints double back-slashes (\
). Understood!
But why in the following code:
class ReplaceTest
{
public static void main(String[] args)
{
String s = "hello.world";
s = s.replaceAll("\.", "");
System.out.println(s);
}
}
is the output:
helloworld
instead of
hello\world
After all, the replaceAll()
method is replacing a dot (\.
) with (\\
).
Can someone please explain this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…