Please review - 6984084 - String repeat()
david.holmes at oracle.com
Wed Aug 15 18:54:54 PDT 2012
On 16/08/2012 4:41 AM, Jim Gish wrote:
> Please review http://cr.openjdk.java.net/~jgish/6984084-StringRepeat/
> This in response to an old RFE to add either a new constructor or a
> method to repeat a string, such as "*".repeat(5) resutling in "*****"
> There is nothing particularly lambda related in here other then the fact
> that under the covers I'm using StringJoiner.
I don't think this can, or should, only be discussed on lambda-dev.
String is immutable so the docs there are wrong for the return value.
I think n should be >=1. You only have a repeat if there are at least
two copies of it: the original plus the repeated copy. So I don't like
converting to empty string in any circumstances.
> I'm happy with the name "repeat" but question the "addNcopies" method in
> AbstractStringBuilder -- suggestions welcome.
replicate seems appropriate to me.
> -- Jim Gish | Consulting Member of Technical Staff | +1.781.442.0304
> Oracle Java Platform Group | Core Libraries Team 35 Network Drive
> Burlington, MA 01803 jim.gish at oracle.com
More information about the lambda-dev