Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Instance Variable Initail Values

 
Jenny Jha
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
as we know in Java all the instance variable are initialized to there default values and so on...
Now we can see at many places instance variable being given some default values for e.g.
protected Object myObject = null;

Now my question is the above mentioned way of programming is a good programming practice or it has some other meaning too.

Thanks

Jenny
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As not all programmers can remember the default values, then explicitly assigning values makes the code easier to read.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic