This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the differece between exception and error
 
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Java In General (Beginner) forum...
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Error stop the execution of the program. You are not to be able to recover from Error using try-catch statement.
For example UnsatisfiedLinkError means that JVM couln't find native language definition of a method. Your program couldn't continue without these method.

The exception shows you that something goes wrong but you could recover the state of the program, the program could continue.
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, any exception can be caught but some exceptions are considered unlkely to be handled successfully by a try/catch statement.

All exceptions are subclasses of Throwable. Subclasses of Error, which extends Throwable, are hardware/software errors that are usually beyond the scope of application code. Similarly, subclasses of RuntimeException, which extends Exception, which in turn extends Throwable, represent software errors (like OutOfMemoryError) that would be hard to predict in advance well enough to handle.

This leaves all subclasses of Exception that are not also subclasses of RuntimeException. These are called checked exceptions and must always be either caught by a try/catch statement or explicitly passed to the calling method by a throws clause. Checked exceptions are considered sufficiently predictable and potentially correctable that the programmer should think about handling them and show his/her decision in the code.
[ October 04, 2004: Message edited by: Mike Gershman ]
 
I love a woman who dresses in stainless steel ... and carries tiny ads:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!