📜  如何在java代码示例中使用带有char的while语句

📅  最后修改于: 2022-03-11 14:52:21.433000             🧑  作者: Mango

代码示例1
private static char getHighLow(Scanner keyboard) 
{
    System.out.println("High, Low, or Sevens (H/L/S): ");
    String choiceString = keyboard.next();

    char choice = choiceString.charAt(0);

    while (choice != 'H' || choice != 'h' || choice != 'L' || choice != 'l' || choice != 'S' || choice != 's')
    {
        System.out.println("You have entered an invalid entry.");
        System.out.println("High, Low, or Sevens (H/L/S): ");
        choiceString = keyboard.next();
    }

    return choice;

}