First of all make sure you are not using all caps and second of all make sure you are using the right numbers and sutch that you can look up on google.
Explanation:
try{
String[] names={"Tom","Suzie","Lina","Harry","Rosy"};
Scanner input=new Scanner(System.in);
System.out.println("Enter an integer: ");
int position=input.nextInt();
System.out.println(names[position]);
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("Subscript out of range.");
}