• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null and ""

 
Art DeSeve
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are null and "" the same thing? I thought they were but now I am wondering.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They most certainly are NOT the same thing.
null is a special literal value used to indicate an un-initialized reference. Instance variables are initialized to null. If you try to perform an operation on an object reference that has the null value you get a NullPointerException.
"" is a String object that has zero characters it it.
Bill

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic