--- old/./src/share/classes/java/lang/String.java 2012-08-21 16:41:05.001708604 -0400 +++ new/./src/share/classes/java/lang/String.java 2012-08-21 16:41:04.893708606 -0400 @@ -2362,6 +2362,30 @@ } /** + * Returns a new {@code String} whose value is {@code n} concatenated copies of the + * current value. If {@code n == 0}, then an empty string is returned. + * If {@code n == 1}, then the current {@code String} is returned. + * + * @param n the number of times the current value is concatenated to itself + * @return a reference to this String or a new String depending on the value of n + * @throws IllegalArgumentException if n < 0 + * @since 1.8 + */ + public String repeat( int n ) { + if (n < 0) { + throw new IllegalArgumentException( "n < 0"); + } + if (n == 0) { + return ""; + } + if (n == 1) { + return this; + } + + return new StringBuilder().append(n, this).toString(); + } + + /** * Converts all of the characters in this {@code String} to lower * case using the rules of the given {@code Locale}. Case mapping is based * on the Unicode Standard version specified by the {@link java.lang.Character Character}