This technique replaces the characters in a substring of this StringBuffer with a font in the specified String. The substring starts at the specified begin and enlarges to the value at index end - 1 or to the end of the StringBuffer, if no such value exists. First, the characters in the substring are take away and then the particular String is inserted at the start.
Here is the syntax for this method:
public StringBuffer replace(int start, int end, String str)
Here is the detail of parameters:
public class Test { public static void main(String args[]) { StringBuffer sb = new StringBuffer("abcdefghijk"); sb.replace(3, 8, "ZARA"); System.out.println(sb); } }
This will produce the following result:
abcZARAijk
Here at Intellinuts, we have created a complete Java tutorial for Beginners to get started in Java.