This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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!