This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
answer to ur question
Posted by Ramesh on November 10, 2000 at 2:20 AM
> we have Query about the memory allocation for final Variables..
> when we write a code like this..
> final int a =10;
> byte b = a;
> As the rule of Variable casting we need here excplicit cast
> but this code complied successfully..and the value of b will be 10
> Why this is occuring and How?
> pls. anyone who knows the answer..explain us with variable memory alloction.
> Hema and Ruchi
ur final integer variable value is with in the range of byte(between 1 and 127).since it is a final variable it can not be changed.so there is no problem as there is no chance of changing the content of a final variable at runtime.thats way its a valid statement.
if u assign a = 128 it will give a compilation error