Java - Cast

> Procedural Languages > Java

1 - About

Cast is a coercion function.

The cast method of Class is the dynamic analog of Java's cast operator.

It casts an object to the class or interface represented by the Class object.

It simply checks that its argument is an instance of the type represented by the Class object.

If so, it returns the argument; otherwise it throws a ClassCastException.

3 - Code

public class Class<T> {
    T cast(Object obj);
}

4 - Documentation / Reference

Advertising
lang/java/cast.txt · Last modified: 2018/03/15 10:52 by gerardnico