how to use a while statement with char in java

Solutions on MaxInterview for how to use a while statement with char in java by the best coders in the world

showing results for - "how to use a while statement with char in java"
Stefano
03 Feb 2017
1    private static char getHighLow(Scanner keyboard) 
2{
3    System.out.println("High, Low, or Sevens (H/L/S): ");
4    String choiceString = keyboard.next();
5
6    char choice = choiceString.charAt(0);
7
8    while (choice != 'H' || choice != 'h' || choice != 'L' || choice != 'l' || choice != 'S' || choice != 's')
9    {
10        System.out.println("You have entered an invalid entry.");
11        System.out.println("High, Low, or Sevens (H/L/S): ");
12        choiceString = keyboard.next();
13    }
14
15    return choice;
16
17}