The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2000



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 Artima Forums.


answer to ur question

Posted by Ramesh on November 10, 2000 at 2:20 AM

> hi..

> 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.

> ThankX
> 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 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


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us