posted 19 years ago
Don't forget, there are also rules about automatic implcit narrowing promotion.
Fore example.
byte b = 3; //Ok,
int i = 3;
byte c = i; //Not ok, not resolved at compile time.
So for implicit automatic promotion the following apply:
a) The operand to the right of the assignment operator must be a byte, char, short, or int.
b) Operand on the right must be in the range of the operator on the left
c) Operator on the left must be a byte, short, or char.
Anything else required an implicit cast.
int x = 3L; //Compile error, need a cast
int x = (int) 3L; //OK.
"When the compilers not happy ain't nobody happy"