I am making a program that replaces a specific part of a string.
String x = "hello";
x=x.replaceAll("e","\\\\s");
System.out.println(x);
output: h \ sllo
but for
System.out.println("\\s");
output: \ s
why do we need extra characters in the first case.
source
share