Extending exception class... ?

Sharky Forums


Results 1 to 2 of 2

Thread: Extending exception class... ?

  1. #1
    Expensive Sushi
    Join Date
    Aug 2001
    Location
    Canada, BC
    Posts
    28

    Post Extending exception class... ?

    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).]

  2. #2
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077

    Post

    If you want to handle the Exception right then and there, than you could simply put the statement into a Try / Catch block.

    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{
    ....
    }



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •