Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object references that are not initialized

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers ,
I am confused here

Is this true ?

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


 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but only if they are fields; if they are local variables they may cause a compiler error.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
Clyde DeSouza
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but only if they are fields;
Ritchie fields are always initialised to Zero value if not initialized,not Null!
 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic