Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

what does null mean in java?

800636Mar 28 2010 — edited Mar 28 2010
i have a very basic doubt. what does null mean? when i initialize an object to null then what does it mean?

like if i write
String name=null;
and then when i print it to console
System.out.println(name);
it prints "null"

but how?

when i try to print the string length, it says null pointer exception. Does this mean that name has no length yet.

if yes then, if a String initialized to null has no length then why does "null" get printed.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2010
Added on Mar 28 2010
5 comments
326 views