Skip to content

Commit 08bc59d

Browse files
author
Stuart Marks
committed
8138614: (spec str) StringBuffer and StringBuilder methods improperly require "new" String to be returned
Reviewed-by: rgiulietti, shade, alanb, rriggs, liach
1 parent b17c0b6 commit 08bc59d

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/java.base/share/classes/java/lang/AbstractStringBuilder.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,13 +1027,13 @@ public AbstractStringBuilder replace(int start, int end, String str) {
10271027
}
10281028

10291029
/**
1030-
* Returns a new {@code String} that contains a subsequence of
1030+
* Returns a {@code String} that contains a subsequence of
10311031
* characters currently contained in this character sequence. The
10321032
* substring begins at the specified index and extends to the end of
10331033
* this sequence.
10341034
*
10351035
* @param start The beginning index, inclusive.
1036-
* @return The new string.
1036+
* @return A string containing the specified subsequence of characters.
10371037
* @throws StringIndexOutOfBoundsException if {@code start} is
10381038
* less than zero, or greater than the length of this object.
10391039
*/
@@ -1042,7 +1042,7 @@ public String substring(int start) {
10421042
}
10431043

10441044
/**
1045-
* Returns a new character sequence that is a subsequence of this sequence.
1045+
* Returns a character sequence that is a subsequence of this sequence.
10461046
*
10471047
* <p> An invocation of this method of the form
10481048
*
@@ -1072,14 +1072,14 @@ public CharSequence subSequence(int start, int end) {
10721072
}
10731073

10741074
/**
1075-
* Returns a new {@code String} that contains a subsequence of
1075+
* Returns a {@code String} that contains a subsequence of
10761076
* characters currently contained in this sequence. The
10771077
* substring begins at the specified {@code start} and
10781078
* extends to the character at index {@code end - 1}.
10791079
*
10801080
* @param start The beginning index, inclusive.
10811081
* @param end The ending index, exclusive.
1082-
* @return The new string.
1082+
* @return A string containing the specified subsequence of characters.
10831083
* @throws StringIndexOutOfBoundsException if {@code start}
10841084
* or {@code end} are negative or greater than
10851085
* {@code length()}, or {@code start} is
@@ -1602,11 +1602,10 @@ public AbstractStringBuilder reverse() {
16021602

16031603
/**
16041604
* Returns a string representing the data in this sequence.
1605-
* A new {@code String} object is allocated and initialized to
1606-
* contain the character sequence currently represented by this
1607-
* object. This {@code String} is then returned. Subsequent
1605+
* The {@code String} object that is returned contains the character
1606+
* sequence currently represented by this object. Subsequent
16081607
* changes to this sequence do not affect the contents of the
1609-
* {@code String}.
1608+
* returned {@code String}.
16101609
*
16111610
* @return a string representation of this sequence of characters.
16121611
*/

0 commit comments

Comments
 (0)