• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Final Var ...

 
Enamul Haque
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
like:
int x = 20;
final int finalVar = x;

 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, in fact since you can initialize your final vars in your constructors, they are often initialized with a parameter passed into the constructor.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic