Here is my class, where i am concatenating two string. String concatenate with null using + operator execute smoothly but throws NullPointerException
null
NullPointerException
concate() method creates new String() object under the hood.
concate()
new String()
where as + combines\ concatenates values by using toString() method. That's why when we use + it continents "somevalue".append(null).toString().
+
toString()
"somevalue".append(null).toString()
for reference see this question.