APCS Java Subset

ap.java.lang
Class ClassCastException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.lang.RuntimeException
              extended byap.java.lang.ClassCastException
All Implemented Interfaces:
java.io.Serializable

public class ClassCastException
extends java.lang.RuntimeException

Students should understand this error/exception when it occurs in a program.

An object of this class is thrown when code attempts to cast an object to a subclass of which it is not an instance. For example, the code below generates a ClassCastException.

   Object o = new Integer(42);
   String s = (String) o;       // generates ClassCastException
 

See Also:
Serialized Form

Constructor Summary
ClassCastException()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassCastException

public ClassCastException()

unofficial documentation for the APCS Java Subset