< prev index next >

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

Print this page
rev 54260 : 8221430: StringBuffer(CharSequence) constructor truncates when -XX:-CompactStrings specified


 117      * specified string. The initial capacity of the string builder is
 118      * {@code 16} plus the length of the string argument.
 119      *
 120      * @param   str   the initial contents of the buffer.
 121      */
 122     @HotSpotIntrinsicCandidate
 123     public StringBuilder(String str) {
 124         super(str.coder(), str.length(), 16);
 125         append(str);
 126     }
 127 
 128     /**
 129      * Constructs a string builder that contains the same characters
 130      * as the specified {@code CharSequence}. The initial capacity of
 131      * the string builder is {@code 16} plus the length of the
 132      * {@code CharSequence} argument.
 133      *
 134      * @param      seq   the sequence to copy.
 135      */
 136     public StringBuilder(CharSequence seq) {
 137         super(String.LATIN1, seq.length(), 16);
 138         append(seq);
 139     }
 140 
 141     /**
 142      * Compares two {@code StringBuilder} instances lexicographically. This method
 143      * follows the same rules for lexicographical comparison as defined in the
 144      * {@linkplain java.lang.CharSequence#compare(java.lang.CharSequence,
 145      * java.lang.CharSequence)  CharSequence.compare(this, another)} method.
 146      *
 147      * <p>
 148      * For finer-grained, locale-sensitive String comparison, refer to
 149      * {@link java.text.Collator}.
 150      *
 151      * @param another the {@code StringBuilder} to be compared with
 152      *
 153      * @return  the value {@code 0} if this {@code StringBuilder} contains the same
 154      * character sequence as that of the argument {@code StringBuilder}; a negative integer
 155      * if this {@code StringBuilder} is lexicographically less than the
 156      * {@code StringBuilder} argument; or a positive integer if this {@code StringBuilder}
 157      * is lexicographically greater than the {@code StringBuilder} argument.




 117      * specified string. The initial capacity of the string builder is
 118      * {@code 16} plus the length of the string argument.
 119      *
 120      * @param   str   the initial contents of the buffer.
 121      */
 122     @HotSpotIntrinsicCandidate
 123     public StringBuilder(String str) {
 124         super(str.coder(), str.length(), 16);
 125         append(str);
 126     }
 127 
 128     /**
 129      * Constructs a string builder that contains the same characters
 130      * as the specified {@code CharSequence}. The initial capacity of
 131      * the string builder is {@code 16} plus the length of the
 132      * {@code CharSequence} argument.
 133      *
 134      * @param      seq   the sequence to copy.
 135      */
 136     public StringBuilder(CharSequence seq) {
 137         super(getCharSequenceCoder(seq), seq.length(), 16);
 138         append(seq);
 139     }
 140 
 141     /**
 142      * Compares two {@code StringBuilder} instances lexicographically. This method
 143      * follows the same rules for lexicographical comparison as defined in the
 144      * {@linkplain java.lang.CharSequence#compare(java.lang.CharSequence,
 145      * java.lang.CharSequence)  CharSequence.compare(this, another)} method.
 146      *
 147      * <p>
 148      * For finer-grained, locale-sensitive String comparison, refer to
 149      * {@link java.text.Collator}.
 150      *
 151      * @param another the {@code StringBuilder} to be compared with
 152      *
 153      * @return  the value {@code 0} if this {@code StringBuilder} contains the same
 154      * character sequence as that of the argument {@code StringBuilder}; a negative integer
 155      * if this {@code StringBuilder} is lexicographically less than the
 156      * {@code StringBuilder} argument; or a positive integer if this {@code StringBuilder}
 157      * is lexicographically greater than the {@code StringBuilder} argument.


< prev index next >