Java StringBuffer replace Example
StringBuffer class replace method example. This example shows you how to use replace method.
StringBuffer class replace method example. This example shows you how to use replace method.replace method replaces the characters in a substring of this sequence with characters in the specified String. The substring begins at the specified start and extends to the character at index end - 1 or to the end of the sequence if no such character exists. First the characters in the substring are removed and then the specified String is inserted at start
Here is the code
/**
* @(#) Replace. java
* A class representing replace method
* @Version 01-May-2008
* @author Rose India Team
*/
public class Replace {
public static void main(String args[]) {
StringBuffer sb = new StringBuffer("Rose india");
// Replaces the characters in a substring of this StringBuffer with characters in the specified String.
System.out.println("Length of the buffer string : " + sb.replace(5,6,"I"));
}
} |
null
|