< prev index next >

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

Print this page




 396     public int lastIndexOf(String str) {
 397         return super.lastIndexOf(str);
 398     }
 399 
 400     @Override
 401     public int lastIndexOf(String str, int fromIndex) {
 402         return super.lastIndexOf(str, fromIndex);
 403     }
 404 
 405     @Override
 406     public StringBuilder reverse() {
 407         super.reverse();
 408         return this;
 409     }
 410 
 411     @Override
 412     @HotSpotIntrinsicCandidate
 413     public String toString() {
 414         // Create a copy, don't share the array
 415         return isLatin1() ? StringLatin1.newString(value, 0, count)
 416                           : StringUTF16.newStringSB(value, 0, count);
 417     }
 418 
 419     /**
 420      * Save the state of the {@code StringBuilder} instance to a stream
 421      * (that is, serialize it).
 422      *
 423      * @serialData the number of characters currently stored in the string
 424      *             builder ({@code int}), followed by the characters in the
 425      *             string builder ({@code char[]}).   The length of the
 426      *             {@code char} array may be greater than the number of
 427      *             characters currently stored in the string builder, in which
 428      *             case extra characters are ignored.
 429      */
 430     private void writeObject(java.io.ObjectOutputStream s)
 431         throws java.io.IOException {
 432         s.defaultWriteObject();
 433         s.writeInt(count);
 434         char[] val = new char[capacity()];
 435         if (isLatin1()) {
 436             StringLatin1.getChars(value, 0, count, val, 0);


 396     public int lastIndexOf(String str) {
 397         return super.lastIndexOf(str);
 398     }
 399 
 400     @Override
 401     public int lastIndexOf(String str, int fromIndex) {
 402         return super.lastIndexOf(str, fromIndex);
 403     }
 404 
 405     @Override
 406     public StringBuilder reverse() {
 407         super.reverse();
 408         return this;
 409     }
 410 
 411     @Override
 412     @HotSpotIntrinsicCandidate
 413     public String toString() {
 414         // Create a copy, don't share the array
 415         return isLatin1() ? StringLatin1.newString(value, 0, count)
 416                           : StringUTF16.newString(value, 0, count);
 417     }
 418 
 419     /**
 420      * Save the state of the {@code StringBuilder} instance to a stream
 421      * (that is, serialize it).
 422      *
 423      * @serialData the number of characters currently stored in the string
 424      *             builder ({@code int}), followed by the characters in the
 425      *             string builder ({@code char[]}).   The length of the
 426      *             {@code char} array may be greater than the number of
 427      *             characters currently stored in the string builder, in which
 428      *             case extra characters are ignored.
 429      */
 430     private void writeObject(java.io.ObjectOutputStream s)
 431         throws java.io.IOException {
 432         s.defaultWriteObject();
 433         s.writeInt(count);
 434         char[] val = new char[capacity()];
 435         if (isLatin1()) {
 436             StringLatin1.getChars(value, 0, count, val, 0);
< prev index next >