my program is suppose to add 10 to an array of random numbers when the user enter an integer , the array of random numbers will be displayed and adds 10 to them under the first array and if the user doesn't enter an int then the try catch statement catches the error displaying an error message, so what i want to do is add a loop in the try catch statement that makes the user enter an int when they don't this is what i tried so far and didn't work
public class tryandcatch {
public static void main(String[] args) {
int[] tab=new int[10];
int i;
Scanner inp=new Scanner(System.in);
while(true) {
try{
System.out.println("Please enter an integer number");
i=inp.nextInt();
for(i=0;i<tab.length;i++){
tab[i]=((int)(Math.random()*100));
System.out.print(tab[i]+" ");
}
addTen(tab);
System.out.print("\n");
for(i=0;i<tab.length;i++)System.out.print(tab[i]+" ");
break;
}
catch(InputMismatchException e){
System.out.println("The number must be integer");
i=inp.nextInt();
}
}
}
static void addTen(int[] x){
int i;
for(i=0;i<x.length;i++) x[i]+=10;
}
}