File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes final variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "final variables" Watch "final variables" New topic

final variables

Anirban dutta
Ranch Hand

Joined: Aug 08, 2002
Posts: 89
what is the difference between the following codes:
1)code one:
public static void main(String []args)
final int i = 100;
byte b = i;
2)Code two:
public static void main(String []args)
int i = 100;
byte b = i;
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

Check out the Java Language Specification for a formal definition:final (�4.5.4)
Basically, a variable declared final is a constant -- its value cannot be changed once assigned.

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
wood burning stoves
subject: final variables
Similar Threads
Tell me Why ?
Primitive assignment
What is the output for First Snippet and Second Snippet?
automatic primitive conversion from higher to lower precision?????
Conversions with final keyword please helpme understand