I am trying to replace a +
character into a hyphen
I have in my string.
String str = \"word+word\";
str.replaceAll(\'+ \', \'-\');
Use
str = str.replaceAll("\\+", "-");
A few errors in your code :
+
char must be escaped as the first argument is a regular expression (and \
itself must be escaped in java string literals)