cast

An explicit conversion written (Type)value that tells the compiler to treat a value as another type, and throws at run time if it is not.

In more detail

If the value is not actually of the target type, the cast throws InvalidCastException at run time. Generics and type patterns remove most casts, moving the failure from run time to compile time.

Related terms

Taught in

References