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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
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
I agree. Here's the link:
subject: final variables
It's not a secret anymore!