Before the addition, binary numeric promotion (�5.6.2) is performed on the value 1 and the value of the variable. If necessary, the sum is narrowed by a narrowing primitive conversion (�5.1.3) to the type of the variable before it is stored.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Originally posted by Ajith Kallambella:
Let me try..
Explicit casting required wherever narrowing conversion is required.
The famous examples,
<PRE>
byte a = 1 ;
byte b = 2 ;
byte c = a + b ; // Error!
int i = 1 ;
byte j = 1 ; // Error WHY WOULD THIS BE AN ERROR?
final int k = 1 ;
byte m = k ; // No Error
</PRE>
I am sure this covers most of it, though it may not be complete.
Feel free to comment/balk/scream/thrash me if I am wrong!!
Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |