Java: loop infinito usando o Scanner in.hasNextInt ()

Estou usando o seguinte código:

while (invalidInput)
{
    // ask the user to specify a number to update the times by
    System.out.print("Specify an integer between 0 and 5: ");

    if (in.hasNextInt())
    {
        // get the update value
        updateValue = in.nextInt();

        // check to see if it was within range
        if (updateValue >= 0 && updateValue <= 5) 
        { 
            invalidInput = false; 
        } 
        else 
        {
            System.out.println("You have not entered a number between 0 and 5. Try again.");
        }
    } else
    {
        System.out.println("You have entered an invalid input. Try again.");
    }
}

No entanto, se eu inserir um 'w', ele me dirá "Você digitou uma entrada inválida. Tente novamente". e então entrará em um loop infinito mostrando o texto "Especifique um inteiro entre 0 e 5: Você inseriu uma entrada inválida. Tente novamente."

Por que isso está acontecendo? O programa não deve esperar que o usuário insira e pressione enter toda vez que ele atingir a instrução:

if (in.hasNextInt())

questionAnswers(4)

yourAnswerToTheQuestion