Specifications

Sun Services
Java™ Programming Language
Module 4, slide 17 of 31
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Promotion and Casting of Expressions
Variables are promoted automatically to a longer form
(such as int to long).
Expression is assignment-compatible if the variable type
is at least as large (the same number of bits) as the
expression type.
long bigval = 6; // 6 is an int type, OK
int smallval = 99L; // 99L is a long, illegal
double z = 12.414F; // 12.414F is float, OK
float z1 = 12.414; // 12.414 is double, illegal