View RSS Feed

Tutorial

Java exception tutorials.

  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. Basics of Exceptions

    by , 11-29-2011 at 03:09 AM
    One of the key aspects of programming is understanding how to handle exceptions. An exception is a problem that prevents the continuation of the current method or scope. It’s important to distinguish an exceptional condition from a normal problem, in which you have enough information in the current context to somehow cope with the difficulty. With an exception, you cannot continue processing because you lack the information necessary to address the problem in its current context. The only recourse ...

    Updated 11-30-2011 at 03:19 AM by Java Exception

    Categories
    Error Handling , Tutorial
  3. Catching an Exception

    by , 11-29-2011 at 03:07 AM
    Following on from our previous tip on exceptions, in this tip we will look at catching an exception. One of the key concepts to understand is the concept of a guarded region. It is a section of code that might produce exceptions and is followed by the code to handle a particular exception. They are often grouped into all the possible exceptions for a particular method or piece of code.

    The try block
    The first part of the region is the try block. This is when you’re inside a ...