[Chapter 12] ClassCastException
Author: Mark Grand and Jonathan Knudsen
Date: Fri Aug 8 16:59:54 1997

#

| Chapter 12 The java.lang Package |

# ClassCastException

## Name

ClassCastException

## Synopsis

Class Name:

  `java.lang.ClassCastException`

Superclass:

  `java.lang.RuntimeException`

Immediate Subclasses:

  None

Interfaces Implemented:

  None

Availability:

  JDK 1.0 or later

## Description

A `ClassCastException` is thrown when there is an attempt to cast a reference to an object to an inappropriate type.

## Class Summary

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

## Constructors

### ClassCastException

#### public ClassCastException()

Description

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

#### public ClassCastException(String s)

Parameters

  `s`

    The detail message.

Description

  This constructor creates a `ClassCastException` 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

`Exception`, `RuntimeException`, `Throwable`

Class |  | ClassCircularityError