diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index 968e96241b8..5de256966c1 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -2180,14 +2180,23 @@ public final class String * *
The {@code limit} parameter controls the number of times the * pattern is applied and therefore affects the length of the resulting - * array. If the limit n is greater than zero then the pattern - * will be applied at most n - 1 times, the array's - * length will be no greater than n, and the array's last entry - * will contain all input beyond the last matched delimiter. If n - * is non-positive then the pattern will be applied as many times as - * possible and the array can have any length. If n is zero then - * the pattern will be applied as many times as possible, the array can - * have any length, and trailing empty strings will be discarded. + * array. + *
+ * If the limit is positive then the pattern will be applied + * at most limit - 1 times, the array's length will be + * no greater than limit, and the array's last entry will contain + * all input beyond the last matched delimiter.
+ * If the limit is zero then the pattern will be applied as + * many times as possible, the array can have any length, and trailing + * empty strings will be discarded.
+ * If the limit is negative then the pattern will be applied + * as many times as possible and the array can have any length.
The string {@code "boo:and:foo"}, for example, yields the * following results with these parameters: diff --git a/src/java.base/share/classes/java/util/regex/Pattern.java b/src/java.base/share/classes/java/util/regex/Pattern.java index dc74eb669ba..cd7cd39f55d 100644 --- a/src/java.base/share/classes/java/util/regex/Pattern.java +++ b/src/java.base/share/classes/java/util/regex/Pattern.java @@ -1193,14 +1193,23 @@ public final class Pattern * *
The {@code limit} parameter controls the number of times the * pattern is applied and therefore affects the length of the resulting - * array. If the limit n is greater than zero then the pattern - * will be applied at most n - 1 times, the array's - * length will be no greater than n, and the array's last entry - * will contain all input beyond the last matched delimiter. If n - * is non-positive then the pattern will be applied as many times as - * possible and the array can have any length. If n is zero then - * the pattern will be applied as many times as possible, the array can - * have any length, and trailing empty strings will be discarded. + * array. + *
+ * If the limit is positive then the pattern will be applied + * at most limit - 1 times, the array's length will be + * no greater than limit, and the array's last entry will contain + * all input beyond the last matched delimiter.
+ * If the limit is zero then the pattern will be applied as + * many times as possible, the array can have any length, and trailing + * empty strings will be discarded.
+ * If the limit is negative then the pattern will be applied + * as many times as possible and the array can have any length.
The input {@code "boo:and:foo"}, for example, yields the following * results with these parameters: