Creating Your Own Exceptions - Java Object Oriented Design

Java examples for Object Oriented Design:Exception

Introduction

Exception classes typically have two constructors:

  • The first takes no arguments, and
  • the second takes a single string as an argument.

Exception classes are like other classes.

public class MyException extends Exception { 
    public MyException () {} 

    public MyException (String message) { 
        super (message); 
    } 
}

Related Tutorials