public
class Main
{
   public static void main (String args[])
   {
      Tablica tab = new Tablica();
      int value = 0;
      try{
         value = tab.getElement(20);
      }
      catch(ArrayIndexOutOfBoundsException e){
         System.out.println("Nie ma elementu o numerze 20!");
         System.exit(-1);
      }
      System.out.println("Element nr 20 to: " + value);
   }
}

public
class Tablica
{
   int tab[];
   public Tablica()
   {
      tab = new int[5];
   }
   int getElement(int index)
   throws ArrayIndexOutOfBoundsException
   {
      return tab[index];
   }
}
