Click to See Complete Forum and Search --> : Extending exception class... ?


Klion
12-02-2001, 09:15 PM
Alright i need to make a class for a Java Applet which throws an exception if a number is >0 or <10. I think i have to extend the exception class to do this but im not sure what i should put in my class if i do this... Anyway, someone mind giving me a hand?

-Kli

[This message has been edited by Klion (edited December 02, 2001).]

Grizzly
12-02-2001, 10:57 PM
If you want to handle the Exception right then and there, than you could simply put the statement into a Try / Catch block. (http://java.sun.com/docs/books/tutorial/essential/exceptions/catch.html)

If you'd rather have your Class throw the Exception, than simply add "throws Exception" or "throws ArithmeticException" to your class definition.

Example:
public class SharkyForums throws Exception{
....
}