Umesh,
In
Java String objects are immutable. Meaning once created, it's content NEVER changes. But the StringBuffer object's content is changable.
So for the 1st qstn which you posted used StringBuffer, when calls method1(StringBuffer sb1,StringBuffer sb2), after the method returns , the content of the originally passed StringBuffer is changed to "Hi Umesh".
But when the same method is slightly modified to take String as an arg, after the method is called, eventhough we tried to concat the input arg String sb1 with "Umesh" inside the method(String sb1, String sb2), what happened inside the method was a NEW String object was created, and the original String object passed to this method was UNTOUCHED. This proves the immutablity of String object.
You may find this
particular discussion useful.
regds
maha anna
[This message has been edited by maha anna (edited March 29, 2000).]