• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is null ?

 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers ,

what is null in java , i think it is not a keyword , is it a value ??


thanx in advance
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume the null of java is as good as the void* of C. It works in the same fashion. I do not think that it is a value.
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume null is a special literal in Java and it can be cast to any reference type which represents empty(which is not existing).
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Codean:
I presume the null of java is as good as the void* of C. It works in the same fashion. I do not think that it is a value.


Hi Codean, you display name does not follow JavaRanch naming policy. You can have a look at JavaRanch naming policyand crrect it.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
null is a keyword. It works much like NULL in C++ (not void* since null is not a type, it is a value). null simply means that a reference variable does not refer to any object.

Layne
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Layne]: null is a keyword.

Not according to Sun's definition. "While true and false might appear to be keywords, they are technically Boolean literals (�3.10.3). Similarly, while null might appear to be a keyword, it is technically the null literal (�3.10.7)." The difference appears to have literal practical value, since just about the only thing they do with the definition is tell us that we can't have an identifier that matches a keyword... or a boolean literal or null literal. And all three of these are incorporated in the definition of token. Big deal. It looks like "keyword" never appears in any definition in which the null literal and boolean literals aren't also included, so it would've made sense to group them all together in the first place. Regardless though, for whatever reason, Sun chose to group them separately.
 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers ,

So null is a special literal and is of primtive type , correct me if i am wrong .


Thanx in advance
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by faisal usmani:
correct me if i am wrong .


OK: you're wrong. null is a literal of reference type.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Yingst:
The difference appears to have literal practical value


Cute typo
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic