Forums Register Login

What is null ?

+Pie Number of slices to send: Send
Hello ranchers ,

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


thanx in advance
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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).
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
[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.
+Pie Number of slices to send: Send
Hello ranchers ,

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


Thanx in advance
+Pie Number of slices to send: Send
 

Originally posted by faisal usmani:
correct me if i am wrong .



OK: you're wrong. null is a literal of reference type.
+Pie Number of slices to send: Send
 

Originally posted by Jim Yingst:
The difference appears to have literal practical value



Cute typo
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 856 times.
Similar Threads
Confused: request.getParameter("userName") returns null
HTTP Status 500
NullpointerExceptin while creating rootPOA
JSP Exception 500 Error
Values of Hash Map to be 2-dimensional array
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:19:21.