Hi Vijayalakshmi,
In the first example, you declared 'i' as 'final' variable with a value of '100'.
Whenever you declare a final variable in Java, the compiler
optimizes the bytecode to use the declared value in place of the variable reference (at least, that's the net result). So the compiler changes the code to do something like
'100' is within the correct range for a 'byte' so Assignment Conversion (
see JLS §5.2 ) rules apply and no error is generated.
In your second example, 'i' is not 'final', implying that it's value can change at any point during execution. The compiler does
not optimize the bytecode. It sees 'i' as any
integer value; you cannot assign
any integer to a byte; only those within -128 to 128 so a compile error occurs.
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform