Type Conversions
A critical part of understanding data types in a programming language is knowing how expressions that contain different types are evaluated. For example, how does the language handle situations where a float is assigned to a double or a byte is added to an int? Java is a strongly typed language, so issues like this are resolved at compile time. Extensive type checking is performed (to help detect programmer errors) and strict restrictions are imposed on which values can be converted from one type to another.
There are really two different kinds of conversions:
Implicit conversions occur any time a value is of a different type than that required in an expression and the compiler can safely convert it to what is required. ...
Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.