This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Instance Variable Initail Values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Instance Variable Initail Values" Watch "Instance Variable Initail Values" New topic

Instance Variable Initail Values

Jenny Jha

Joined: Feb 23, 2008
Posts: 1
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.


Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
As not all programmers can remember the default values, then explicitly assigning values makes the code easier to read.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Have you checked out Aspose?
subject: Instance Variable Initail Values
It's not a secret anymore!