Nicolas De Loof wrote:


It is supported in jdk1.3.. Just cast the stringbuffer passed in to an object, so like StringBuffer.append((Object) StringBuffer)). Much more efficient than an if...


Surely a StringBuffer is already an Object?

Or am I missing something here?

StringBuffer has a new method in Java 1.4 to append another Stringbuffer without invoking it's toSring() method. Code that uses StringBuffer.append(stb) and compiled by a JDK 1.4 will not work on Java 1.3. I miself recommand Using "StringBuffer.append(stb.toString())" that looks better than an apparently useless (Object) cast : checkstyle or IDE may warn for unecessary cast.

Also may be a solution, which looks more readable. Though I fixed all these StringBuffer issues I had personally by adding the not very useless Object cast (this way you prevent the usage of the overloaded method which takes a StringBuffer). This way I don't have to worry whats under the covers , which in this case is according to you a toString().

Mvgr,
Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to