I'm trying to create a Hangman game but I don't know how to properly initialize the wordDisplay array, it gives an error this array is supposed to print out underscores for letters of the word to guess and then the underscores get replaced by letters that were guessed by the player
public class Hangman
{
static Scanner userInput = new Scanner(System.in);
public static void main(String args[])
{
String strword = "wordo";
char[] theWord = strword.toCharArray();
int k = strword.length();
int c;
char[] wordDisplay;
for(c=0;c<=k;c++)
{
wordDisplay[c] = '_';
}
int hang = 0;
int i;
while(hang<k+10)
{
System.out.println("type a letter");
for(i=0;i<5;i++)
{
System.out.print( wordDisplay[i] );
}
char userLetter = userInput.next().charAt(0);
for(i=0;i<=k;i++)
{
if(userLetter==theWord[i])
{
System.out.println("a letter guessed");
wordDisplay[i] = theWord[i];
}
else
{
hang++;
}
}
}
System.out.println("you hang");
}
}