131 * the specified initial capacity.
132 *
133 * @param capacity the initial capacity.
134 * @throws NegativeArraySizeException if the {@code capacity}
135 * argument is less than {@code 0}.
136 */
137 @HotSpotIntrinsicCandidate
138 public StringBuffer(int capacity) {
139 super(capacity);
140 }
141
142 /**
143 * Constructs a string buffer initialized to the contents of the
144 * specified string. The initial capacity of the string buffer is
145 * {@code 16} plus the length of the string argument.
146 *
147 * @param str the initial contents of the buffer.
148 */
149 @HotSpotIntrinsicCandidate
150 public StringBuffer(String str) {
151 super(str.coder(), str.length(), 16);
152 append(str);
153 }
154
155 /**
156 * Constructs a string buffer that contains the same characters
157 * as the specified {@code CharSequence}. The initial capacity of
158 * the string buffer is {@code 16} plus the length of the
159 * {@code CharSequence} argument.
160 *
161 * @param seq the sequence to copy.
162 * @since 1.5
163 */
164 public StringBuffer(CharSequence seq) {
165 super(String.LATIN1, seq.length(), 16);
166 append(seq);
167 }
168
169 /**
170 * Compares two {@code StringBuffer} instances lexicographically. This method
171 * follows the same rules for lexicographical comparison as defined in the
172 * {@linkplain java.lang.CharSequence#compare(java.lang.CharSequence,
173 * java.lang.CharSequence) CharSequence.compare(this, another)} method.
174 *
175 * <p>
176 * For finer-grained, locale-sensitive String comparison, refer to
177 * {@link java.text.Collator}.
178 *
179 * @implNote
180 * This method synchronizes on {@code this}, the current object, but not
181 * {@code StringBuffer another} with which {@code this StringBuffer} is compared.
182 *
183 * @param another the {@code StringBuffer} to be compared with
184 *
185 * @return the value {@code 0} if this {@code StringBuffer} contains the same
186 * character sequence as that of the argument {@code StringBuffer}; a negative integer
|
131 * the specified initial capacity.
132 *
133 * @param capacity the initial capacity.
134 * @throws NegativeArraySizeException if the {@code capacity}
135 * argument is less than {@code 0}.
136 */
137 @HotSpotIntrinsicCandidate
138 public StringBuffer(int capacity) {
139 super(capacity);
140 }
141
142 /**
143 * Constructs a string buffer initialized to the contents of the
144 * specified string. The initial capacity of the string buffer is
145 * {@code 16} plus the length of the string argument.
146 *
147 * @param str the initial contents of the buffer.
148 */
149 @HotSpotIntrinsicCandidate
150 public StringBuffer(String str) {
151 super(str);
152 }
153
154 /**
155 * Constructs a string buffer that contains the same characters
156 * as the specified {@code CharSequence}. The initial capacity of
157 * the string buffer is {@code 16} plus the length of the
158 * {@code CharSequence} argument.
159 *
160 * @param seq the sequence to copy.
161 * @since 1.5
162 */
163 public StringBuffer(CharSequence seq) {
164 super(seq);
165 }
166
167 /**
168 * Compares two {@code StringBuffer} instances lexicographically. This method
169 * follows the same rules for lexicographical comparison as defined in the
170 * {@linkplain java.lang.CharSequence#compare(java.lang.CharSequence,
171 * java.lang.CharSequence) CharSequence.compare(this, another)} method.
172 *
173 * <p>
174 * For finer-grained, locale-sensitive String comparison, refer to
175 * {@link java.text.Collator}.
176 *
177 * @implNote
178 * This method synchronizes on {@code this}, the current object, but not
179 * {@code StringBuffer another} with which {@code this StringBuffer} is compared.
180 *
181 * @param another the {@code StringBuffer} to be compared with
182 *
183 * @return the value {@code 0} if this {@code StringBuffer} contains the same
184 * character sequence as that of the argument {@code StringBuffer}; a negative integer
|