```
public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    Random random = new Random();
    String word[] = { "apple" };

    char wordguess[] = word[random.nextInt(word.length)].toCharArray();
    int totalOfGuesses = wordguess.length;
    char[] userGuess = new char[totalOfGuesses]; // save the users input

    System.out.print("Please input your guess : ");
    char input = scanner.nextLine().charAt(0);
}

```

How can I check user input if it is valid or invalid input?  

then, if it is valid, store it in an array called value  

otherwise, save the character in the array called invalid.  

thank for help 

For example:  

valid:\_ \_ \_ \_ \_ invalid:\_ \_ \_ \_ \_  

Please input your guess : a 

For example:  

valid: a \_ \_ \_ \_ invalid:\_ \_ \_ \_ \_  

Please input your guess : a 

For example:  

valid: a \_ \_ \_ \_ invalid:b \_ \_ \_ \_  

Please input your guess : b 

For example:  

valid: a \_ \_ \_ \_ invalid:b \_ \_ \_ \_ 
Please input your guess : b (will not save b again)