The value of String object is understandable because strings are immutable so any changes made in the mehod will not effect the original String. But why does setting the StringBuffer to null does not effect its value. After all StringBuffr is not immutable and any changes made to it in the method should have an effect in the original StringBuffer object. i know i am not getting it right. please help
After the append, the object where "sb" references to has a value of "bbbaaabbb". "sb = null;" removes the reference to that object, but the original "sb" (that one in the main method) still refers to that object. The whole clue is, that when you pass an object as an argument to a method, you pass a copy of the reference to that object. So by setting the copy reference to null, doesn't mean that the original will be set to null..