File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception types

 
Andry Dub
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Is there difference between exceptions typically thrown by JVM/Programmatically and Runtime/Checked exceptions?
 
mr Morena
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andry Dub:
Hi!

Is there difference between exceptions typically thrown by JVM/Programmatically and Runtime/Checked exceptions?


in java programing: you can catch runtime error with try/catch.

try{
badExpressions;
}catch(RuntimeException ex)
{

}

but any error by jvm,will stop your program and running fail.
indeed you can't catch jvm error(exception)!
 
chris java
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Is there difference between exceptions typically thrown by JVM/Programmatically and Runtime/Checked exceptions?


A RuntimeException (and any subclass) is an unchecked exception, so it is not required to be caught. The default consequence of an unchecked exception is that a message will be sent to the console.

An Error (and any subclass) is also an unchecked exception, although I believe most Errors result in the JVM halting processing. Hence, there isn't much point in trying to catch an Error, becuase is is unlikely that the code could recover from it.

All other exceptions are checked exceptions. This means that code calling the method(s) that throw the exception must have a try/catch block.

This link might also help: http://java.sun.com/docs/books/tutorial/essential/exceptions/runtime.html
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic