Return a string consisting of the specified character, repeated. @param theChar the character to repeat @param length number of repetitions @return the string @exception IllegalArgumentException if length is negative.
(char theChar, final int length)
| 96 | * @exception IllegalArgumentException if <code>length</code> is negative. |
| 97 | */ |
| 98 | public static String repeat(char theChar, final int length) { |
| 99 | if (length < 0) { |
| 100 | throw new IllegalArgumentException("bad length"); |
| 101 | } |
| 102 | final char[] buf = new char[length]; |
| 103 | Arrays.fill(buf, theChar); |
| 104 | return new String(buf); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Faster implementation of string splitting on a single character delimiter. |