int [] array = new int [100];
.............................
Scanner input = new Scanner(System.in);
int index=-1;
if(input.hasNextInt())
index = input.nextInt();
try { System.out.println(array[index]);}
catch(IndexOutOfBoundsException e) {
if (index<0) {
//.............
} else if (index>array.length-1) {
//.............
}
}