This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages 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