After initializing with the String itself, you can then use replaceAll to change every character to underscore.
String .contains()
Collapse
X
-
-
ok im back to the reason i started this thread as my method isn't doing the job,
Code:private void setFeedback() { int test = codeWord.indexOf(currentGuess); while(test != -1) { feedback.setCharAt(test, currentGuess); test = codeWord.indexOf(test, currentGuess); } }
I have tried with test and test + 1 which api says is where to start check from.
I thought ii'd sorted this one!Comment
-
sorry jos i know you are trying to help and have lost patience but #18 refers to replacing all charaters in stringbuffer with _. which i ve put on backburner for now.
My last question was more or less the same as the first in thios thread.
I know how to indexOf() for one character but the method i ve just pasted was a while loop to continue checking for multiple occurences b ut it's not doing it's job which as far as the api goes, it should.
Code:private void setFeedback() { int test = codeWord.indexOf(currentGuess); while(test != -1) { feedback.setCharAt(test, currentGuess); test = codeWord.indexOf(test, currentGuess); } }
Comment
-
I'm sorry for trying your patience today jos!
I got to the bottom of it in the end, it was just a case of having test and aChar the wrong way around.
Thank you so much for sticking in there!!
BrendanComment
Comment