I've been trying to remove a specific character from an Array of Strings but continue to fail. The char is "$", I don't know what I'm doing wrong so hoping someone would be able to point to the right direction, my code:
for (int y = 0; y<possibleAnswers.length;y++) {
display = possibleAnswers[y].replaceAll("$", "");
System.out.println(display);
}
possibleAnswers contains 4 Strings, one of the 4 has a "$", I want to remove it before displaying it.
When I run the above code, the "$" is displayed, any ideas?
replaceAll. You should read documentation and discover, thatreplaceAllis the method for replacing the regular expression, not just the exact matching string. Herereplaceshould be used.$has special meaning which is end of line. Means, You are replacing end of line character with blank.