File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Final variables

 
Bharadwaj Adepu
Ranch Hand
Posts: 99
  • 0
  • 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: 47232
52
  • 0
  • 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).
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic