Mega Code Archive

 
Categories / Java Book / 001 Language Basics
 

0082 Type Conversion and Casting

If the two types are compatible, then Java will perform the conversion automatically. For example, assign an int value to a long variable. For incompatible types we must use a cast. Casting is an explicit conversion between incompatible types.