StringBuffer replace(int startIndex,int endIndex,String str)
The String is to be replaced is specified by starting and ending index.Thus substring at startIndex through endIndex-1 is replaced.
CODING:
class replace{
public static void main(String args[])
{
StringBuffer sb = new StringBuffer("This is test");
System.out.println("Original String:"+sb);
sb.replace(5,7,"was");
System.out.println("After Replace:"+sb);
}
}
0 comments:
Post a Comment