I've been trying to create a Hangman game in Java, and I have a string that looks like "_____" for a certain number of letters that they are supposed to represent. How would I replace just one of those, rather than all? I've heard that you can't replace an underscore with the String.replace method, but I couldn't figure it out with Pattern and Matcher. Here's the code:
String b = "____";
char c = b.charAt(0);
b = b.replace(c, 'a');
System.out.println(b);
Please respond as soon as you can! Thanks!