wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Difference between Throwable and Exception class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between Throwable and Exception class" Watch "Difference between Throwable and Exception class" New topic
Author

Difference between Throwable and Exception class

balaji sudheer bandi
Greenhorn

Joined: Sep 05, 2007
Posts: 1
What is the difference between Throwable and Exception classes.
What is the good procedure to develop user defined exceptions ,by either extending Throwable or Exception class.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

This isn't really the right place to ask that question. We have a forum dedicated to Java In General (beginner) questions. When you ask a question in the most appropriate forum, not only are you more likely to get an answer, you'll probably get a better quality answer, since that's where the experts on the subject will be looking. Also, it keeps from cluttering other forums with questions that don't pertain to the forum topic.

But, for a short answer: Throwable is the root of all sequence-interrupting events, including java.lang.Exception. Usually, application developers will want to subclass java.lang.Exception. For more details, I encourage you to ask the folks in the Java In General forum.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Moving this to the forum suggested by Tim

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14115
    
  16

Generally, when you create your own exception class, you should either subclass Exception (if you want a checked exception) or RuntimeException (if you want an unchecked exception). Throwable is the superclass for all exceptions and errors and should not be subclassed directly.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Krithika Srinath
Ranch Hand

Joined: Apr 11, 2006
Posts: 52
To add to the previous notes..

It is rarely good practice for a method to catch Throwable. One such scenario could be when you want to log the error message. In general, errors and exceptions should not be masked from the caller.

You can checkthis doc for more details.
 
Don't get me started about those stupid light bulbs.
 
subject: Difference between Throwable and Exception class