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

casting a primitive type comparison table
Subject use have example have syntax done involve has definition is a kind of
casting 
(String)i.next()
   The process of producing a new value that has a different type than its sourcemechanism
casting a primitive typeto convert a primitive type to an object
//i is an int
//d is a double
(double) i // a double expression
(int) d // an int expression
// note that the original types of i and d remain the same
(typename)valueexplicitly if the destination type is smaller than the source type to avoid loss of precisiona Boolean type casting

Next castingcasting an object    Upcasting