Results 1 to 3 of 3
  1. #1
    John_28 is offline Member
    Join Date
    May 2008
    Rep Power

    Default Handle exception manually

    Can anyone tell me how to handle ArrayIndexOutOfBound exception without using try catch block ?


  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Cebu City, Philippines
    Rep Power


    That exception occurs if the specific task attempt to access the element of (let say)an array which is not initialized, greater than the maximum length, less than 0.

    If you carefully manipulate that array, then that exception will never be thrown....(No need a try/catch block)

    And try/catch block was designed to catch the thrown exceptions coming from the specific function who fails to do its task...(Against the machine)
    freedom exists in the world of ideas

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power


    Simple way if you want to do such a thing is, before doing any process on the array validate the number of elements on it. It has a range, as the above post say greater that or equal to zero and less than or equal to defined length of the array.

Similar Threads

  1. How to handle socket Exception
    By mayank0512 in forum Networking
    Replies: 14
    Last Post: 12-22-2010, 12:31 AM
  2. [SOLVED] Handle own exception
    By stevemcc in forum New To Java
    Replies: 3
    Last Post: 04-10-2008, 05:55 AM
  3. Better way to handle exceptions
    By javaplus in forum Advanced Java
    Replies: 2
    Last Post: 01-16-2008, 07:47 PM
  4. handle wrong input int/null
    By Camden in forum New To Java
    Replies: 1
    Last Post: 12-16-2007, 10:37 PM
  5. how to handle exceptions
    By paty in forum Advanced Java
    Replies: 2
    Last Post: 08-05-2007, 05:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts