Java   View all facts   Glossary   Help
mechanism > casting > casting an object
Next castingcasting a primitive type    Upcasting

casting an object
subjectfact 
casting an objectcan only be performed if the source and destination types of the object are related by inheritance - one class must be a subclass of the otheradded by: JK, source: Teach Yourself Java 2 in 21 Days, 2001-10-19 11:36:17.0
cannot be used to convert an object to a primitive type - use a wrapper class insteadadded by: JK, source: Teach Yourself Java 2 in 21 Days, 2001-10-19 11:36:17.0
has syntax (classname)objectadded by: JK, source: Teach Yourself Java 2 in 21 Days, 2001-10-19 11:36:17.0
is a subtopic of Objects2001-10-19 11:36:18.0
is a kind of casting2001-10-19 11:36:18.0
may be done implicitly if the destination type is a subclass of the source typeadded by: JK, source: Teach Yourself Java 2 in 21 Days, 2001-10-19 11:36:18.0
must be done explicitly if the destination type is a superclass of the source typeadded by: JK, source: Teach Yourself Java 2 in 21 Days, 2001-10-19 11:36:18.0
castinghas example
(String)i.next()    
2001-10-19 11:36:17.0
has purpose to convert an instance of one data type into another which is a subclass of the original type2001-10-19 11:36:17.0