Does a final variable initialized in overloaded constructors differently. Then what about the necessity of intializing a variable at the declartion?
ramesh kumar
Greenhorn
Joined: Aug 15, 2006
Posts: 25
posted
0
we can only initialize final variables once.
Tanka Banerjee
Ranch Hand
Joined: Aug 16, 2006
Posts: 64
posted
0
Do it. final can't be reintialized
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
I'm not sure what these guys are celebrating with their . But to answer the question in a useful way, there is no requirement to initialize a final variable at declaration. For an instance variable, the requirement is that it needs to be assigned before the constructor completes. If you want t assign a final variable in a constructor, you must not assign it at declaration, since a final variable may be assigned only once. vijayk, does that answer your question?
"I'm not back." - Bill Harding, Twister
Dana Bothner-By
Ranch Hand
Joined: Jul 28, 2006
Posts: 37
posted
0
Hmmm... Your first sentense no verb.
Anyway, don't forget to assign a value in *every* constructor: