This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Final variables

 
Bharadwaj Adepu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In the above code the constructor is setting a value to the final variable name.
How is that possible? This runs fine and prints FINAL VARIABLE!
Please explain.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48967
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A final field or variable can be set up once and once only. That can be done at declaration, in an initialiser (fields only) or in the constructor (again fields only).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic