Java Exception catch array index of out bound exception

Description

Java Exception catch array index of out bound exception

public class Main {
  public static void main(String[] args) {

    try {/*from  w w  w  . jav  a  2s .com*/
      int[] a = new int[4]; 
      a[5] =  6; 
    } catch (ArrayIndexOutOfBoundsException e) {
      System.out.println("ArrayIndexOutOfBoundsException: occurred.");

    }
    System.out.println("After catch block");
  }
}



PreviousNext

Related