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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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: 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
    
  15

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
    
    3

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
        
        1
    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
        
        3

    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
        
      13

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