Possible Duplicate:
Concatenating null strings in Java
Please find below the code snippet
String str = null;
str = str + "hi";
System.out.println(str)
The output of the above code is nullhi.
I thought the output will be hi, so kind of surprised with the output and not able to find the reason behind it.
Can someone please explain it.
From JLS.
http://docs.oracle.com/javase/specs/jls/se7/html/index.html
§15.18.1. String Concatenation Operator + (reference)
§5.1.11. String Conversion (reference)