This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Object references that are not initialized Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Object references that are not initialized " Watch "Object references that are not initialized " New topic
Author

Object references that are not initialized

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Hi Ranchers ,
I am confused here

Is this true ?

Object references that are not initialized
explicitly will have their value set to null always



If you want something you never had do something which you had never done
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37890
    
  22
Yes, but only if they are fields; if they are local variables they may cause a compiler error.
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528

Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37890
    
  22
You're welcome
Clyde DeSouza
Greenhorn

Joined: Mar 16, 2009
Posts: 26
Yes, but only if they are fields;
Ritchie fields are always initialised to Zero value if not initialized,not Null!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Joywish Man wrote:
Yes, but only if they are fields;
Ritchie fields are always initialised to Zero value if not initialized,not Null!

We're talking about object references, not numeric primitives. Zero is not a valid value for an obect reference.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Object references that are not initialized
 
Similar Threads
Object references that are not initialized .. (true?)
Initialization
Mock Exam quesions
Object Ref
what is the output and how..