ClassCastException
Last edit July 14, 2006
Exception thrown in
JavaLanguage
during runtime when an attempt is made to cast an object reference to an incompatible type. And - which is often forgotten - this includes cases of the
same
Class loaded by another
ClassLoader
.
ClassCastException
is an
UncheckedException
(descended from
RuntimeException
) and so it need not be caught in code.
Other
DynamicallyTyped
ProgrammingLanguages
like
ObjectiveCee
are nice in that you never ever have this problem.
Sure you do; in
SmalltalkLanguage
it's called
DoesNotUnderstand
. And it's caught later, when you attempt to invoke an operation on an object that isn't supported, rather than at the point of the cast.
CategoryException
CategoryJava