5. Operators and Expressions

Image

5.1 Conversions

In this section we first discuss the different kinds of type conversions that can be applied to values; in the next section we discuss the contexts in which these conversions are permitted. Some type conversions must be explicitly stated in the program, while others are performed implicitly. Some type conversions can be checked at compile time to guarantee their validity at runtime, while others will require an extra check at runtime.

Widening and Narrowing Primitive Conversions

For the primitive data types, the value of a narrower data type can be converted to a value of a wider data type. This ...

Get A Programmer’s Guide to Java® SE 8 Oracle Certified Associate (OCA) now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.