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

Print this page




 383     /**
 384      * @throws NullPointerException {@inheritDoc}
 385      */
 386     public int lastIndexOf(String str) {
 387         return lastIndexOf(str, count);
 388     }
 389 
 390     /**
 391      * @throws NullPointerException {@inheritDoc}
 392      */
 393     public int lastIndexOf(String str, int fromIndex) {
 394         return String.lastIndexOf(value, 0, count,
 395                               str.toCharArray(), 0, str.length(), fromIndex);
 396     }
 397 
 398     public StringBuilder reverse() {
 399         super.reverse();
 400         return this;
 401     }
 402 






























 403     public String toString() {
 404         // Create a copy, don't share the array
 405         return new String(value, 0, count);
 406     }
 407 
 408     /**
 409      * Save the state of the <tt>StringBuilder</tt> instance to a stream
 410      * (that is, serialize it).
 411      *
 412      * @serialData the number of characters currently stored in the string
 413      *             builder (<tt>int</tt>), followed by the characters in the
 414      *             string builder (<tt>char[]</tt>).   The length of the
 415      *             <tt>char</tt> array may be greater than the number of
 416      *             characters currently stored in the string builder, in which
 417      *             case extra characters are ignored.
 418      */
 419     private void writeObject(java.io.ObjectOutputStream s)
 420         throws java.io.IOException {
 421         s.defaultWriteObject();
 422         s.writeInt(count);


 383     /**
 384      * @throws NullPointerException {@inheritDoc}
 385      */
 386     public int lastIndexOf(String str) {
 387         return lastIndexOf(str, count);
 388     }
 389 
 390     /**
 391      * @throws NullPointerException {@inheritDoc}
 392      */
 393     public int lastIndexOf(String str, int fromIndex) {
 394         return String.lastIndexOf(value, 0, count,
 395                               str.toCharArray(), 0, str.length(), fromIndex);
 396     }
 397 
 398     public StringBuilder reverse() {
 399         super.reverse();
 400         return this;
 401     }
 402 
 403     /**
 404      * @throws NullPointerException {@inheritDoc}
 405      * @since 1.7
 406      */
 407     @Override
 408     public StringBuilder join(String delimiter, Object first, Object... elements) {
 409         super.join(delimiter, first, elements);
 410         return this;
 411     }
 412     
 413     /**
 414      * @throws NullPointerException {@inheritDoc}
 415      * @since 1.7
 416      */
 417     @Override
 418     public StringBuilder join(String delimiter, Object[] elements) {
 419         super.join(delimiter, elements);
 420         return this;
 421     }
 422     
 423     /**
 424      * @throws NullPointerException {@inheritDoc}
 425      * @since 1.7
 426      */
 427     @Override
 428     public StringBuilder join(String delimiter, Iterable<?> elements) {
 429         super.join(delimiter, elements);
 430         return this;
 431     } 
 432     
 433     public String toString() {
 434         // Create a copy, don't share the array
 435         return new String(value, 0, count);
 436     }
 437 
 438     /**
 439      * Save the state of the <tt>StringBuilder</tt> instance to a stream
 440      * (that is, serialize it).
 441      *
 442      * @serialData the number of characters currently stored in the string
 443      *             builder (<tt>int</tt>), followed by the characters in the
 444      *             string builder (<tt>char[]</tt>).   The length of the
 445      *             <tt>char</tt> array may be greater than the number of
 446      *             characters currently stored in the string builder, in which
 447      *             case extra characters are ignored.
 448      */
 449     private void writeObject(java.io.ObjectOutputStream s)
 450         throws java.io.IOException {
 451         s.defaultWriteObject();
 452         s.writeInt(count);