Not able to replace all for dollar sign
It is special character you need to use escape character
Try with this \\$
and it doesn't make sense in your code you are trying to replacing the content with same
String message = "$$hello world $$";
message = message.replaceAll("\\$", "_");
System.out.println(message);
output
__hello world __
Update
String message = "$hello world $$";
message = message.replaceAll("$", "\\$");
System.out.println(message);
output
$hello world $$
Since you're not really using any regex so instead of replaceAll you should be using String#replace method like this:
message = message.replace("$", "$");