posted 17 years ago
Hey Buddy,
Whenever you are assigning a high storage variable to a low storage variable, you need to type cast. In this case, int occupies 32 bits and byte occupies only 8 bits. Hence
When you have
it won't compile. It will compile if you say
However, when you qualify a variable with final modifier, it will work because, now i is considered as a constant. This is as good as saying
Whenever, we assign constatns/literal, Compiler takes care of the type casting which is called internal type casting as long as that literal is within the range of the type.
Hope this helps
PMP CSQA SCJP SCWCD SCBCD INS 21 INS 23