• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why this method does not throw error?

 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I was trying to go through with exception handling and found that any exception thrown by a method should be catch. but when I tried following code it works and have not shown any error while compiling while the method as per javadoc throws IndexOutOfBoundsException.




Could you help me to understand.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

any exception thrown by a method should be catch


Not every exception, only so-called checked exceptions. Note that Integer.parseInt also throws an unchecked exception. Unchecked exceptions are those that extend java.lang.RuntimeException and java.lang.Error.

See http://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html for more details. (You may actually wish to work through the entire tutorial on exceptions: http://docs.oracle.com/javase/tutorial/essential/exceptions/index.html.)
 
reply
    Bookmark Topic Watch Topic
  • New Topic