File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes What is Null in Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "What is Null in Java?" Watch "What is Null in Java?" New topic
Author

What is Null in Java?

Nagaraj Shivaklara
Ranch Hand

Joined: Dec 16, 2008
Posts: 75
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
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3056
    
  33

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: 4523
    
    5

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: 12678
        
        5
    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
    Saloon Keeper

    Joined: Aug 16, 2005
    Posts: 13875
        
      10

    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: 19543
        
      16

    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 - OCEEJBD 6
    How To Ask Questions How To Answer Questions
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60055
        
      65

    Of the synonyms for "nothing" shown by thesaurus.com, the keywords I'd have preferred are: naught, nihility, zilch , or (my favorite) annihilation.


    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Randall Twede
    Ranch Hand

    Joined: Oct 21, 2000
    Posts: 4339
        
        2

    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
    Visit my download page
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: What is Null in Java?
     
    Similar Threads
    JSP Exception 500 Error
    Confused: request.getParameter("userName") returns null
    NullpointerExceptin while creating rootPOA
    HTTP Status 500
    Values of Hash Map to be 2-dimensional array