//import Scanner class
import java.util.Scanner;
class ArrayIndexOutOfBoundsExc
{
// define main method from where execution of program starts
public static void main(String args[])
{
//define array in java
int a[]=new int[5];
//create object of scanner class
Scanner sc = new Scanner(System.in);
System.out.println("Enter elements: ");
// Handling array index
try
{
for(int i=0; i<=7; i++)
{
a[i]=sc.nextInt();
}
}
catch(Exception e)
{
System.out.println("We got array index of bounds exception.");
}
// if exception handled then you can continue rest of program
System.out.println("Enter your name: ");
String name=sc.next();
}
}