| Author |
What is Null in Java?
|
Nagaraj Shivaklara
Ranch Hand
Joined: Dec 16, 2008
Posts: 72
|
|
Hi,
I want to know about null. Is it an Object? Does it has size? What actually in real applications null is???
Thanks
Nagaraj
|
Thanks n Regards,
Nagaraj S K
|
 |
Mohamed Sanaulla
Bartender
Joined: Sep 08, 2007
Posts: 2926
|
|
null is definitely not an object. Its some value that is not existent.
|
Mohamed Sanaulla | My Blog
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4163
|
|
From the JLS
3.10.7 The Null Literal
The null type has one value, the null reference, represented by the literal null, which is formed from ASCII characters. A null literal is always of the null type.
NullLiteral:
null
4.12.5 Initial Values of Variables
:
:
:
For all reference types (ยง4.3), the default value is null.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12267
|
|
Given that all Java memory allocation sets the locations to zero, the value in memory for a null reference is zero.
Not something you should worry about or try to fool with.
Bill
|
Java Resources at www.wbrogden.com
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12909
|
|
William Brogden wrote:Given that all Java memory allocation sets the locations to zero, the value in memory for a null reference is zero.
If you set a variable to null, then what the actual bits of the reference in memory look like depends on JVM implementation details. It doesn't necessarily have to be zeroes. But it's not something you need to be concerned about, because you can't access the direct value of a reference variable anyway.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
In Visual Basic, the equivalent value of null is called Nothing. I find that name more descriptive than null.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56179
|
|
|
Of the synonyms for "nothing" shown by thesaurus.com, the keywords I'd have preferred are: naught, nihility, zilch , or (my favorite) annihilation.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Randall Twede
Ranch Hand
Joined: Oct 21, 2000
Posts: 4089
|
|
to answer your implied question. we sometimes set things to null in our programs to "erase"(delete) them.
or (my favorite) annihilation.
ah yes, Total Annihilation, one of my all time favorite games.
|
SCJP
|
 |
 |
|
|
subject: What is Null in Java?
|
|
|