Within this method the String buildWord is used at if(this.guessedLetters.contains(buildWord))
, when i run the testProgram with the main file, i get the incorrect results, but when I manually use if(this.guessedLetters.contains("" + letter))
, it works. My question is what is the difference here?? Why are these two not the same: if(this.guessedLetters.contains(buildWord))
, and if(this.guessedLetters.contains("" + letter))
public String hiddenWord() {
char letter = ' ';
String hiddenWord = "";
String buildWord = "" + letter;
int i = 0;
while (i < this.word.length()) {
letter = this.word.charAt(i);
if (this.guessedLetters.contains(buildWord)) { // **********
hiddenWord += letter;
} else {
hiddenWord += '_';
}
i++;
}
return hiddenWord;
}