do{
System.out.println("Enter a number between 1 and 1024 :"); //asking user to enter a number between 1 and 1024
try{
num=sc.nextInt();
}
catch(InputMismatchException e){
System.out.println("Not an integer!");
}
}while(num<0 || num>1024);
Basically I'm testing a working program and i was trying to fix it so if the user enters, for example 'a', instead of an integer - the program won't crash. however, this resulted in an infinite loop and doesn't really work. any ideas why?