aspose file tools*
The moose likes Beginning Java and the fly likes when will be final fileds loaded Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "when will be final fileds loaded" Watch "when will be final fileds loaded" New topic
Author

when will be final fileds loaded

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
Hi,
When will be final fields get loaded?
and what are the advantages of being final varaibles and eing final static variable?

thanks,
Sai


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689


Is it a right way to declare final where ever i used in thi program?
Anoobkumar Padmanabhan
Ranch Hand

Joined: Aug 08, 2007
Posts: 103
But, is there any need to specify the parameter of constructor as final???
I think no...


Thanks<br /> <br />Anoobkumar<br />SCJP 1.5
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Originally posted by Anoobkumar Padmanabhan:
But, is there any need to specify the parameter of constructor as final???
I think no...


Some folks believe it makes sense to declare all parameters as final. Modifying the parameters of a method can lead to confusing code, and marking them as final prevents that.


[Jess in Action][AskingGoodQuestions]
Anoobkumar Padmanabhan
Ranch Hand

Joined: Aug 08, 2007
Posts: 103
Hi Friedman-Hill


Modifying the parameters of a method can lead to confusing code, and marking them as final prevents that.


I couldn't get the meaning of that. Could you please explain that concept?
Ravikanth kolli
Ranch Hand

Joined: Feb 10, 2008
Posts: 179

As far as i can think, EFH means that people do believe that declaring parameters as final do help, because the parameter cannot be modified and thus prevents erroneous code.


-kolli
 
 
subject: when will be final fileds loaded
 
Similar Threads
Why local inner classes CAN "see" final variables?
FINAL instance variable
Basic concept for memory allocation
final variable
Array Initialization Doubt