• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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: 43028
76
  • 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.)
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic