< prev index next >
src/java.base/share/classes/java/lang/CharSequence.java
Print this page
@@ -235,6 +235,21 @@
new CodePointIterator(),
Spliterator.ORDERED),
Spliterator.ORDERED,
false);
}
+
+ /**
+ * Returns a {@code CharSequence} of specified length representing repetitions
+ * of the same character.
+ *
+ * @param c the character to be repeated
+ * @param length the length of resulting {@code CharSequence}
+ * @return a {@code CharSequence} of {@code length} repetitions of
+ * character {@code c}.
+ * @throws IllegalArgumentException if given {@code length} is negative
+ * @since 10
+ */
+ static CharSequence repetitions(char c, int length) {
+ return new CharRepetitions(c, length);
+ }
}
< prev index next >