• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why this method does not throw error?  RSS feed

 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • 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.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!