File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is Null in Java?

 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to know about null. Is it an Object? Does it has size? What actually in real applications null is???

Thanks
Nagaraj
 
Mohamed Sanaulla
Saloon Keeper
Pie
Posts: 3159
33
Google App Engine Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
null is definitely not an object. Its some value that is not existent.

 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  •  
    William Brogden
    Author and all-around good cowpoke
    Rancher
    Posts: 13045
    6
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    Jesper de Jong
    Java Cowboy
    Saloon Keeper
    Pie
    Posts: 15150
    31
    Android IntelliJ IDE Java Scala Spring
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Rob Spoor
    Sheriff
    Pie
    Posts: 20372
    44
    Chrome Eclipse IDE Java Windows
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    In Visual Basic, the equivalent value of null is called Nothing. I find that name more descriptive than null.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64173
    83
    IntelliJ IDE Java jQuery Mac Mac OS X
    • 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Of the synonyms for "nothing" shown by thesaurus.com, the keywords I'd have preferred are: naught, nihility, zilch , or (my favorite) annihilation.
     
    Randall Twede
    Ranch Hand
    Posts: 4353
    2
    Java
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic