Name: rmT116609 Date: 05/19/2003
A DESCRIPTION OF THE REQUEST :
The java.util.Collection defines a clear() method to remove all elements, I know StringBuffer is not part of the collections framework, but it logical to include the clear() method in the StringBuffer class.
I would expect the StringBuffer clear() method to be semantically equivalent to sb.delete(0, sb.length()) - where 'sb' is a StringBuffer instance - but be much more efficient.
Specifically: the clear() function would remove all characters, but leave the capacity unchanged.
Yes, I know I can create a new instance of StringBuffer or use setLength(0), but these are more obscure ways and/or less efficient ways of producing a cleared StringBuffer.
JUSTIFICATION :
Improve readability and efficiency of Java programs (not to mention reducing the irritation caused by going to use an 'obvious' method and finding it missing!).
(Review ID: 186093)
======================================================================
A DESCRIPTION OF THE REQUEST :
The java.util.Collection defines a clear() method to remove all elements, I know StringBuffer is not part of the collections framework, but it logical to include the clear() method in the StringBuffer class.
I would expect the StringBuffer clear() method to be semantically equivalent to sb.delete(0, sb.length()) - where 'sb' is a StringBuffer instance - but be much more efficient.
Specifically: the clear() function would remove all characters, but leave the capacity unchanged.
Yes, I know I can create a new instance of StringBuffer or use setLength(0), but these are more obscure ways and/or less efficient ways of producing a cleared StringBuffer.
JUSTIFICATION :
Improve readability and efficiency of Java programs (not to mention reducing the irritation caused by going to use an 'obvious' method and finding it missing!).
(Review ID: 186093)
======================================================================
- duplicates
-
JDK-6542603 (str) StringBuilder.clear() method
-
- Closed
-