when we declare a string variable as String s = null then the string referrence variable s does not refer to any String object. How does the statement s+=s produce a value of nullnull?? does this mean that when s does not refer to any string object it gets a value of null. but still any other operations on the variable using the dot operator results in nullpointerexception.
This is actually related to the StringBuffer (StringBuilder) class. Normally, when you try to append an object to the string buffer, it will use the toString() method to get the string to append. However, if the object in question is not available (null), the append() method will append the string value of "null".
How is this related? The adding of strings are actually syntactic sugar for append() method calls to string buffers.