I got this lines :
while(flag==0){
try{
code=input.nextInt();
}
catch(java.util.InputMismatchException z)
{
System.out.print("\nDigito(s) Invalidos!\n");
flag=1;
}
finally
{
if(flag==1)
flag=0;
else{flag=1;}
}
}
But the input.nextInt()
only works at the first time. What's the best way to prevent the user to insert a char on an Integer?