Results 1 to 3 of 3
  1. #1
    Hatem's Avatar
    Hatem is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Exclamation How to Extend an Exception in Java (InputMismatchException) ?

    Hi ..

    Am Trying to Customize this Class (InvalidGradeException) to Print A Simple Message When the Exception Handled. Actually I had Try to Do it With Constructor but Cannot. Can you Help me ?

    As you see the Class Inherits From the Exception Class (InputMismatchException).

    Java Code:
    Class InvalidGradeException extends InputMismatchException
    {
    
    }
    Hatem

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    12,999
    Blog Entries
    7
    Rep Power
    19

    Default

    Quote Originally Posted by Hatem View Post
    Hi ..

    Am Trying to Customize this Class (InvalidGradeException) to Print A Simple Message When the Exception Handled. Actually I had Try to Do it With Constructor but Cannot. Can you Help me ?

    As you see the Class Inherits From the Exception Class (InputMismatchException).

    Java Code:
    Class InvalidGradeException extends InputMismatchException
    {
    
    }
    Hatem
    Implement a couple of constructors in your class (that call the superclass' constructors) like this:

    Java Code:
    public class InvalidGradeException extends InputMismatchException {
       public InvalidGradeException() { super(); }
       public InvalidGradeException(String s) { super(s); }
       // other interesting stuff here ...
    }
    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Hatem's Avatar
    Hatem is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

Similar Threads

  1. help instantiate a java class that extend applet
    By geosa in forum Java Applets
    Replies: 0
    Last Post: 12-04-2010, 09:14 AM
  2. try-catch InputMismatchException in a while loop
    By themulator in forum New To Java
    Replies: 17
    Last Post: 10-12-2010, 04:49 AM
  3. Extend Jscroll
    By cowboy in forum New To Java
    Replies: 10
    Last Post: 12-13-2009, 08:07 PM
  4. How can I extend java.net.URI - why is it final?
    By johann_p in forum Advanced Java
    Replies: 1
    Last Post: 08-21-2009, 05:31 AM
  5. using J-classes or extend them ?
    By itaipee in forum AWT / Swing
    Replies: 1
    Last Post: 01-01-2009, 07:58 PM

Tags for this Thread

Posting Permissions

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