I'm still pretty new to Java so bear with me. I'm making a simple hangman game that takes input from the user. I am trying to append the guessed letter to the knownLetters array but I get a type mismatch. I tried .concat() and got the same type error. Here is where I am now. Any ideas or documentation resources (that a novice can read) would be helpful. Thanks!
Edit: Thanks for the comments, everyone! These are very helpful.
public static boolean updateWithGuess(char[] knownLetters,
char guessedLetter,
String word) {
System.out.println(Arrays.toString(knownLetters));
int i = 0;
while(word.indexOf(i, guessedLetter) != -1) {
i = word.indexOf(i, guessedLetter) + 1;
knownLetters += guessedLetter;
list, where you can remove and append items freelyArrayorListuseStringBuilderand there you can append all the guessed characters. And when ever you want to check whether acharacteris present in the StringBuilder or not, justconvertStringBuilderto String and usecontains()function.+=wouldn't even compile. This is not the way to append to an Array (apart from the fact that Arrays are fixed size as already mentioned in comments)StringBuilderalready hascharAtorindexOf, both of which are much more efficient than creating unnecessary strings.