Check and avoid if a char is being entered in a int
- by John
Hi.... This is a exremely stupid question but i need help with this.... I'm trying to make a small program that i made robust and needed some help with tht....
int num1;
int num2 = 0;
System.out.print("Enter number 1: ");
num1 = kb.nextInt();
while(num2<num1)
{
System.out.print("Enter number 2: ");
num2 = kb.nextInt();
}
Number 2 has to be greater than number 1
Also i want the program to automatically check and ignore if the user enters a char instead of an int... Cause right now when a user enters lets say "r" instead of a number the program just exists....