0

Can someone tell the binary value for null? I know its JVM dependent but can someone tell me how it actually works ? How does JVM allocate a address for null? Does it stays constant throughout until system restarts?

Develop4Life
  • 7,581
  • 8
  • 58
  • 76
  • 4
    I think there is no way to find the value for null. But this may help you to know what null exactly is. [Link](http://stackoverflow.com/questions/2707322/what-is-null-in-java) – SASIKUMAR SENTHILNATHAN Jul 02 '15 at 09:17
  • Have a look. http://stackoverflow.com/questions/2707322/what-is-null-in-java – Abhishek Saxena Jul 02 '15 at 09:21
  • Why would you want to know? It's not possible to ever use this knowledge, as a Java program cannot gain access to the representation of a pointer in Java. It's only useful when you want to debug a JVM, and since you don't think it's important to mention which JVM you want to know this for, you're probably not going to do that. – Erwin Bolwidt Jul 02 '15 at 09:25
  • The most straightforward implementation of `null` is indeed to set it to a fixed and known invalid address. I would expect most JVMs to follow this pattern (if only because C does it too) but you never know until you look. – biziclop Jul 02 '15 at 09:37
  • to be honest handling null and JVM or C driven JVM thing or C itself is no wonder.Because , those are driven form C itself except Java added it own high level abstraction to manage thing like memory! so null is pointer in C and Java but manager on later! Adios! – Develop4Life Jul 03 '15 at 05:46

1 Answers1

0

'Null' in java or most often in programming language with empty initialization who don't have nulls consume a memory space.It does refer to a variable who value is pointing to a null value but created in memory.

For Example:

String nullString = null ; declares 16 byte memory but point to null value.

Even Though u mean null memory is used to reference the variable in this case nullString later.

**Let say you wanna

String nullString = "10"; 

//still this time consumes the same 
 bytes because it already declared but value pointer is changed this time!**

To be honest handling null and JVM or C driven JVM thing or C itself is no wonder.Because , those are driven form C itself except Java added it own high level abstraction to manage thing like memory! so null is pointer in C and Java but manager on later! Adios!

Develop4Life
  • 7,581
  • 8
  • 58
  • 76