Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8197594

String#repeat

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 11
    • None
    • core-libs
    • None
    • b04
    • generic
    • generic

      A String method for repeating sequences of characters has been long requested with no follow through. There are also have been requests for repeat counts on Appendable#append but that would require significant coordination of Appendable implementations, including StringBuilder. Having basic repeat functionality the String will suffice for now.

          /**
           * Returns a string whose value is the concatenation of this
           * string repeated {@code count} times.
           * <p>
           * If this string is empty or count is zero then the empty
           * string is returned.
           *
           * @param count number of times to repeat
           *
           * @return A string composed of this string repeated
           * {@code count} times or the empty string if this
           * string is empty or count is zero
           *
           * @throws IllegalArgumentException if the {@code count} is
           * negative.
           *
           * @since 11
           */
          public String repeat(int count) {

      Webrev: http://cr.openjdk.java.net/~jlaskey/8197594/webrev-02/index.html
      JavaDoc: http://cr.openjdk.java.net/~jlaskey/8197594/String.html

            jlaskey Jim Laskey
            jlaskey Jim Laskey
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: