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 Var ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Final Var ..." Watch "Final Var ..." New topic

Final Var ...

Enamul Haque

Joined: Jun 07, 2003
Posts: 21
From the Java Tutorial I came to know about he final keyword and a example.......
final int aFinalVar = 3;
and it also says that a variable once called as final can't be initialized more that once. i.e. it's like const of C++.
Now my question is that can I change init it with other variables ofcourse once.
int x = 20;
final int finalVar = x;

<b><i>We all are the components of a huge program...... the programmer is always debugging us with His debugger.</b></i>
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Yes, in fact since you can initialize your final vars in your constructors, they are often initialized with a parameter passed into the constructor.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
I agree. Here's the link:
subject: Final Var ...
It's not a secret anymore!