aspose file tools
The moose likes Beginning Java and the fly likes Final variables Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Final variables" Watch "Final variables" New topic
Author

Final variables

Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99


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.


SCJP 1.5
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32651
    
    4
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).
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Final variables
 
Similar Threads
final variable initialisation(simple code)
in Interface the instance variables are final, right?So what happens in this code?
Final and immutable
Is this an implicit cast?
Implemetinng the interface with all static final variables