从Java 11开始,有个方法String::repeat这正是你所要求的:String str = "abc";String repeated = str.repeat(3);repeated.equals("abcabcabc");/**
* Returns a string whose value is the concatenation of this
* string repeated {@code count} times.
*
* 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
*/