Java Reference
In-Depth Information
Start public boolean equals(Object otherObject)
Warning: This is the method inherited from Object . It is not overridden for the class
StringBuffer and does not work as you might expect. Normally, it should not be used.
public int indexOf(String aString)
Returns the index (position) of the fi rst occurrence of the string aString in the calling object.
Positions are counted 0, 1, 2, etc. Returns − 1 if aString is not found. Note that the argument is
of type String , not StringBuffer .
Throws:
NullPointerException if aString is null.
public int indexOf(String aString, int start)
Returns the index (position) of the fi rst occurrence of the string aString in the calling object
that occurs at or after position start . Positions are counted 0, 1, 2, etc. Returns − 1 if aString
is not found. Note that the argument is of type String , not StringBuffer .
Throws:
NullPointerException if aString is null.
public int lastIndexOf(String aString)
Returns the index (position) of the last occurrence of the string aString in the calling object
string. Positions are counted 0, 1, 2, etc. Returns − 1 if aString is not found. Note that the
argument is of type String , not StringBuffer .
Throws:
NullPointerException if aString is null.
public int length()
Returns the length of the calling object as a value of type int .
public StringBuffer replace( int start, int end, String ordinaryString)
Replaces the characters in a substring of the calling object with characters in the ordinaryString .
The substring begins at the specifi ed start and extends to the character at index end −1 or to the
end of the calling object if no such character exists. First the characters in the substring are removed
and then the specifi ed ordinaryString is inserted at start . (The calling object will be length-
ened to accommodate the ordinaryString if necessary.) Note that the calling object is changed
and a reference to the changed calling object is returned.
Throws:
StringIndexOutOfBoundsException if start is negative, greater than length() , or greater
than end . StringIndexOutOfBoundsException is a derived class of RuntimeException ,
and so is an unchecked exception, which means it is not required to be caught or declared in a
throws clause.
Search WWH ::




Custom Search