Basic Array Index Out of Bounds Example in Java


Here is the simple program for printing basic example of Array Index Out of Bounds Example in Java.

Source Code

import java.io.*;
class array_bound_exp
{
  public static void main(String args[])
  {
    int a[]={50,10,85,88,58};
    try
    {
      a[4]=10;
      System.out.println("\na[0] : "+a[0]);
    }
    catch(Exception e)
    {
      System.out.println(e);
    }
    finally
    {
      System.out.println("Hi");
    }
  }
}
To download raw file Click Here

Output

a[0] : 50
Hi



Learn All in Tamil © Designed & Developed By Tutor Joes