![]() |
mechanism > casting > casting an object |
![]() ![]() | ||||
casting an object | ||||
subject | fact |
casting an object | can only be performed if the source and destination types of the object are related by inheritance - one class must be a subclass of the other | ![]() |
cannot be used to convert an object to a primitive type - use a wrapper class instead | ![]() | |
has syntax (classname)object | ![]() | |
is a subtopic of Objects | ![]() | |
is a kind of casting | ![]() | |
may be done implicitly if the destination type is a subclass of the source type | ![]() | |
must be done explicitly if the destination type is a superclass of the source type | ![]() | |
casting | has example (String)i.next() | ![]() |
has purpose to convert an instance of one data type into another which is a subclass of the original type | ![]() |