./src/share/classes/java/lang/AbstractStringBuilder.java
Print this page
rev 5707 : [mq]: StringRepeat
@@ -1384,10 +1384,33 @@
}
return this;
}
/**
+ * Appends {@code n} concatenated copies of the CharSequence to the
+ * current value. If {@code n == 0}, then adds the empty string. If
+ * @{code cs} is {@code null}, then adds {@code "null"} {@code n} times.
+ *
+ * @param n the number of copies of the CharSequence to concatenate
+ * @param cs the CharSequence to concatenate (n times)
+ * @return a reference to this object
+ * @throws IllegalArgumentException if n < 0
+ * @since 1.8
+ */
+ public AbstractStringBuilder append(int n, CharSequence cs) {
+ if (n < 0) {
+ throw new IllegalArgumentException("n < 0");
+ }
+
+ for (int i = 0; i < n; i++) {
+ append(cs);
+ }
+
+ return this;
+ }
+
+ /**
* Returns a string representing the data in this sequence.
* A new {@code String} object is allocated and initialized to
* contain the character sequence currently represented by this
* object. This {@code String} is then returned. Subsequent
* changes to this sequence do not affect the contents of the