Use a pencil and paper. draw a String and mark the spots and lengths needed for the substring method.
Write a small testing program and experiment.
I'm done for tonight.
Type: Posts; User: Norm
Use a pencil and paper. draw a String and mark the spots and lengths needed for the substring method.
Write a small testing program and experiment.
I'm done for tonight.
Given the String: "1234" and you want to replace the 3 with an "X"
newString = "12" + "X" + "4";
Using substring to get the beginning and ending Strings.
If you can't use StringBuilder class, you'll have to build Strings using substrings and concatenation.
Read the API doc for the replace() method.
When you call it, you did not pass it an index.
If all the char in a String are the same(?) how would the method know which one to replace?
After you...
disguisedWord.replace(letter, secretWord.charAt(i));
What was the value of disguisedWord when the above was executed? Did it contain a char that is in the variable: letter?
Did your debug...
I don't see that type of for statement.
Try debugging the code by adding lots of println statements in the makeGuess() method to show every variables value every time it is tested and changed....