News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

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

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview