News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

A simple Java code which demonstrates the exception handling in Java

Started by sukishan, Jul 15, 2009, 02:00 PM

Previous topic - Next topic

sukishan

public class excep2
{
   public static void main(String args[])
   {
      int i =0 ;
      //Declare an array of strings
      String Box [] = {"Book", "Pen", "Pencil"};
      while(i<4)
      {
         try
         {
            System.out.println(Box);
            
         }
         catch(ArrayIndexOutOfBoundsException e)
         {
            System.out.println("Subscript Problem " + e);
         i++;
         }
         finally
         {
            System.out.println("This is always printed.");
         }
         i++;
      }
   }
}
A good beginning makes a good ending