[Chapter 12] RuntimeException

#

| Chapter 12 The java.lang Package |

# RuntimeException

## Name

RuntimeException

## Synopsis

Class Name:

  `java.lang.RuntimeException`

Superclass:

  `java.lang.Exception`

Immediate Subclasses:

  `java.lang.ArithmeticException`,

  `java.lang.ArrayStoreException`,

  `java.lang.ClassCastException`,

  `java.lang.IllegalArgumentException`,

  `java.lang.IllegalMonitorStateException`,

  `java.lang.IllegalStateException`,

  `java.lang.IndexOutOfBoundsException`,

  `java.lang.NegativeArraySizeException`,

  `java.lang.NullPointerException`,

  `java.lang.SecurityException`,

  `java.util.EmptyStackException`,

  `java.util.MissingResourceException`,

  `java.util.NoSuchElementException`

Interfaces Implemented:

  None

Availability:

  JDK 1.0 or later

## Description

The `RuntimeException` class is the superclass of the standard run-time exceptions that can be thrown in Java. The appropriate subclass of `RuntimeException` is thrown in response to a run-time error detected at the virtual machine level. A run-time exception represents a run-time condition that can occur generally in any Java method, so a method is not required to declare that it throws any of the run-time exceptions.

A Java program should try to handle all of the standard run-time exception classes, since they represent routine abnormal conditions that should be anticipated and caught to prevent program termination.

## Class Summary

    public class java.lang.RuntimeException extends java.lang.Exception {
      // Constructors
      public RuntimeException();
      public RuntimeException(String s);
    }

## Constructors

### RuntimeException

#### public RuntimeException()

Description

  This constructor creates a `RuntimeException` with no associated detail message.

#### public RuntimeException(String s)

Parameters

  `s`

    The detail message.

Description

  This constructor creates a `RuntimeException` with the specified detail message.

## Inherited Methods

Method | Inherited From | Method | Inherited From
--- | --- | --- | ---
`clone()` | `Object` | `equals(Object)` | `Object`
`fillInStackTrace()` | `Throwable` | `finalize()` | `Object`
`getClass()` | `Object` | `getLocalizedMessage()` | `Throwable`
`getMessage()` | `Throwable` | `hashCode()` | `Object`
`notify()` | `Object` | `notifyAll()` | `Object`
`printStackTrace()` | `Throwable` | `printStackTrace(PrintStream)` | `Throwable`
`printStackTrace(PrintWriter)` | `Throwable` | `toString()` | `Object`
`wait()` | `Object` | `wait(long)` | `Object`
`wait(long, int)` | `Object` |  |

## See Also

`ArithmeticException`, `ArrayStoreException`, `ClassCastException`, `EmptyStackException`, `IllegalArgumentException`, `IllegalMonitorStateException`, `IllegalStateException`, `IndexOutOfBoundsException`, `MissingResourceException`, `NegativeArraySizeException`, `NoSuchElementException`, `NullPointerException`, `SecurityException`, `Throwable`

Runtime |  | SecurityException