This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding final

 
RatnaSekhar Kamireddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
there is a line in scjp 5 text book(2 minutes drill)
"final reference variables must be initialized before the constructor completes"

whats the actual meaning of this
please explain this in detail
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In above code comment and uncomment line 4 and see result.
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, the final variable has to be initialized before any constructor completes.
The following will not compile due to the sierra-line. If instantiated with a string as argument, variable i wouldn't get a value. 0€.

Yours,
Bu.
 
RatnaSekhar Kamireddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks i got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic