java · java/ClassCastException
ClassCastException
ClassCastException
Thrown when an object is cast to a type it is not an instance of, e.g. casting an Integer to a String.
Also defined in
- kotlin ClassCastException Thrown at the JVM level when an object is cast to an incompatible type. In idiomatic Kotlin this is usually surfaced as a TypeCastException, but it can originate from Java interop or reflection.
- scala ClassCastException Thrown when asInstanceOf[T] is called on a value that is not an instance of T. Prefer pattern matching to avoid this; in well-typed code it usually indicates an incorrect assumption about a value received from an external source.