RFR: JDK-8197594: String#repeat

Andrej Golovnin andrej.golovnin at gmail.com
Thu Mar 1 07:53:15 UTC 2018


Hi Jim,

src/java.base/share/classes/java/lang/String.java

2972      * This method may be used to create space padding for
2973      * formatting text or zero padding for formatting numbers.
2974      * @param   count number of times to repeat
2975      * @return  A string composed of this string repeated
2976      *          {@code count} times or the empty string if count
2977      *          or length is zero.
2978      * @throws  IllegalArgumentException if the {@code count} is
2979      *          negative.

I don't know whether the JavaDoc style guide requires it or not, but I
would put an empty line before @param, @return and @ throws to
improved readability.

2983             throw new IllegalArgumentException("count is
negative, " + count);

"count is negative, " -> "count is negative: "

test/jdk/java/lang/String/StringRepeat.java

102     static void VERIFY(String result, String string, int repeat) {

Why is the method name in uppercase?

Best regards,
Andrej Golovnin

On Wed, Feb 28, 2018 at 5:31 PM, Jim Laskey <james.laskey at oracle.com> wrote:
> Introduction of a new instance method String::repeat to allow an efficient and concise approach for generating repeated character sequences as strings.
>
> Performance information in JBS.
>
> Thank you.
>
> Cheers,
>
> — Jim
>
>
> JBS: https://bugs.openjdk.java.net/browse/JDK-8197594 <https://bugs.openjdk.java.net/browse/JDK-8197594>
> CSR: https://bugs.openjdk.java.net/browse/JDK-8198296
>  <http://cr.openjdk.java.net/~jlaskey/8197594/String.html>
> Webrev: http://cr.openjdk.java.net/~jlaskey/8197594/webrev-02/index.html <http://cr.openjdk.java.net/~jlaskey/8197594/webrev-02/index.html>
> JavaDoc: http://cr.openjdk.java.net/~jlaskey/8197594/String.html <http://cr.openjdk.java.net/~jlaskey/8197594/String.html>
>
>
>


More information about the core-libs-dev mailing list