The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2001



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.


final means constant

Posted by Kishori Sharan on January 11, 2001 at 12:44 PM

final int i = 100 ;
This makes i a constant. After this declaration if you try to assign a different value to i as in
i = 101 ; you will get error because value of 100 is the final value of i. i cannot be changed afterwards. Some languages use keyword CONSTANT instead of final.
Whereas int i = 100 ;
declares a variable i of type int and initializes it to 100. In this case you can chage the value of i whenever you want lieks
i = 200 ;


Sponsored Links

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