Most visited

Recently visited

Added in API level 1

ClassCastException

public class ClassCastException
extends RuntimeException

java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ java.lang.ClassCastException


抛出以表明代码试图将对象转换为其不是实例的子类。 例如,下面的代码生成一个ClassCastException

     Object x = new Integer(0);
     System.out.println((String)x);
 

Summary

Public constructors

ClassCastException()

构造一个没有详细信息的 ClassCastException

ClassCastException(String s)

用指定的详细信息构造一个 ClassCastException

Inherited methods

From class java.lang.Throwable
From class java.lang.Object

Public constructors

ClassCastException

Added in API level 1
ClassCastException ()

构造一个没有详细信息的 ClassCastException

ClassCastException

Added in API level 1
ClassCastException (String s)

用指定的详细信息构造一个 ClassCastException

Parameters
s String: the detail message.

Hooray!