aspose file tools*
The moose likes Beginning Java and the fly likes override of exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "override of exception" Watch "override of exception" New topic
Author

override of exception

nil lin
Greenhorn

Joined: May 04, 2004
Posts: 4
At first,we can use "throws" to throw exception,
only checked exception can be override,right?
then, there are two rules for override,
how to explain those rules?
thanks a lot!!*^^*
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Hi,
Welcome to JavaRanch!
The term "override" isn't normally used to describe anything to do with exceptions, and I'm afraid I've got no idea what you mean by "two rules." Perhaps you could explain your question a bit more, and perhaps include code if that would help.


[Jess in Action][AskingGoodQuestions]
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
Let me take a stab at it. There are basically two types of exceptions you'll run into, "java.lang.Exception" and "java.lang.RuntimeException".
They function the same way in most respects. You can create your own exception classes that extend either one of them, and if you throw them in a method you have to include it in the "throws ..." clause in the method header.
The major difference is that if you call a method that throws something that subclasses "java.lang.Exception", it MUST be referenced inside of a try/catch block. If you call a method that throws something that subclasses "java.lang.RuntimeException," you do not have to catch it.
Look in the Java API documentation staring at java.lang.Throwable and from there you can navigate to "Exception" and "RuntimeException" to read more about it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: override of exception