Ramaseshan,
Good Question
This is the sequence how the code runs:
1) It does a String.valueOf(null)--> If the null is passed as an argument, literal string "null" is returned
2) Then new StringBuffer("null") is called
3) Finally on the above created StringBuffer object append("abc") method is run.
The final output is a SringBuffer object having contents as "nullabc".
4) At the end toString() is called to return a new String object.
So,
a += "abc" ==> a = (new StringBuffer((String.valueOf(null)).append("abc")).toString();
Hope u got this
But there are some slight changes the way the program runs depending on the variables,
---------------------------------
Now if u have
The way it runs is like this
a = (new StringBuffer((String.valueOf(a)).append(String.valueOf(b))).toString();
----------------------------
Now if u have something like this
The simplified statement is:
a = (new StringBuffer("abc").append(b)).toString();
-----------------------------------------------------------
In the method append() of StringBuffer u have something like this:
I hope u got the point,
Thanks