Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when will be final fileds loaded

 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When will be final fields get loaded?
and what are the advantages of being final varaibles and eing final static variable?

thanks,
Sai
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is it a right way to declare final where ever i used in thi program?
 
Anoobkumar Padmanabhan
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But, is there any need to specify the parameter of constructor as final???
I think no...
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anoobkumar Padmanabhan
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 179
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic