String Handling

351
5147 reads

February 22, 2013

indexOf


These two methods are overloaded in several different ways. In all cases, the methods return the index at which the character or substring was found, or –1 on failure.

97
2603 reads

February 22, 2013

replace()


This method replaces the characters in a substring of this StringBuffer with characters in the specified String.

241
3773 reads

February 22, 2013

Demonstrate delete() and deleteCharAt()


The delete( ) method deletes a sequence of characters from the invoking object.

163
3764 reads

February 22, 2013

Using reverse() to reverse a StringBuffer


This example shows how to reverse the content of the StringBuffer using reverse method of Java StringBuffer class.

383
3720 reads

February 22, 2013

Demonstrate append()


Appends the specified string to this character sequence.

299
4137 reads

February 22, 2013

charAt() and setCharAt()


charAt(int index)

341
4338 reads

February 22, 2013

StringBuffer length vs. capacity


The capacity is the amount of storage available for newly inserted characters, beyond which an allocation will occur.

Obvious length is related to number of characters in string

302
3696 reads

February 22, 2013

toUpperCase() and toLowerCase()


The method toLowerCase( ) converts all the characters in a string from uppercase to lowercase. The toUpperCase( ) method converts all the characters in a string from lowercase to uppercase.

214
3952 reads

February 22, 2013

Using trim()


Returns a copy of the string, with leading and trailing whitespace omitted.

355
5976 reads

February 22, 2013

Substring replacement


String substring(int beginIndex,
int endIndex)