hello can you help me how i can catch the exception...
I want to input integer for my array and i want to catch the exception if i will input a string this will display Invalid input how can i use this in try catch because i am confuse please help me hoping for your positive responds...please correct me if i am wrong...
here is my code
System.out.println("Please Input number in array");
try{
n=console.nextInt();
}
catch(InputMismatchException e)
{
throw new Exception("invalid input");
}
System.out.println("FamilyNames to be process" + " " + n);
String [] list = new String [n];
for(i=0;i<n;i++)
{
list[i]= console.next();
}