Just so you can say sb.append("blah").append("foo").append("bar"); Which is arguably more readable than sb.append("blah"); sb.append("foo"); sb.append("bar"); And a good deal more efficient than sb.append("blah" + "foo" + "bar"); Because the latter needlessly creates a temporary StringBuffer and String. It is amusing (or saddening) how often you see developers use the latter idiom. - Peter

Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898

posted Oct 19, 2001 04:53:00

0

That was fast. Thanks. I understood that return is a copy of reference to StringBuffer instance

Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898

posted Oct 19, 2001 08:43:00

0

Peter. cool! I asked before posting and after posting here a lot of programmers/developers in Java. Nobody could figure out

I still don't understand the original question. (But I think I understand the answer.)

Please ignore post, I have no idea what I am talking about.

Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898

posted Oct 22, 2001 01:10:00

0

Cristopher, why, having understood answer, you could not understand qs. Credits to Peter den Haan!!! Anyway it is even more important (than receiving answer to specific technical qs) to be clear, and to be understood. The questions was: Why StringBuffer's methods, changing the same obj (not same as in case of String's methods), have returns of type StringBuffer but not of type void or boolean? I even could give counter-examples for similar circumstances... Give me a word what should I correct more. [This message has been edited by G Vanin (edited October 24, 2001).]