wood burning stoves
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
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
I agree. Here's the link: http://aspose.com/file-tools
subject: Instance Variable Initail Values
It's not a secret anymore!