Hola que tal, estoy haciendo una funcion para pedir un numero entero, quiero que si el usuario lo inserta mal que lo vuelva a pedir, para ello hice esta funcion:
public static int pedir_entero
(String s
) {
int aux = 0;
boolean correct=false;
Scanner stdin
=new Scanner
(System.
in);
while(correct == false)
{
try
{
aux=stdin.nextInt();
stdin.next();
correct=true;
}
catch(InputMismatchException e)
{
System.
out.
println("ERROR," + s
); }
}
return aux;
}
Cuando la pruebo poniendo una letra, se cuelga el programa mostrandos repetitivamente e infinitamente esta sentencia:
"System.out.println("ERROR," + s);"
Que puede ser? Desde ya gracias y saludos.