View RSS Feed

Java Exception

Java exceptions and errors.

  1. User defined exception

    by , 01-08-2012 at 12:01 PM
    You can customize and write your own user defined exceptions. Following class extends the Exception class and writes a new “MyException” which is thrown at some point in your code.

    Java Code: This is an example of user defined exception
    public class MyException extends Exception {
    /* class definition of constructors goes here */
    public MyException() {
    super();
    }
    public MyException (String errorMessage) {
    super (errorMessage);
    }
    }

    Updated 01-14-2012 at 06:48 PM by Java Exception

    Tags: exception Add / Edit Tags
    Categories
    Tutorial
  2. Java error handling

    by , 01-08-2012 at 11:56 AM
    When a hard failure or link failure occurs in virtual machine, JVM throws an Error. These Errors are not caught by the typical java programs.

    When a problem occurs in the code, an Exception is thrown and is caught by the program explicitly. Base class of all Exception classes is Exception class. All other are derived classes. Below image shows a complete hierarchy of the exceptions in java.

    Name:  62.JPG
Views: 1093
Size:  16.3 KB

    Throwable and subclasses

    ...