You are here: Home / Topics / stringBuffer replace () method example in Java

stringBuffer replace () method example in Java

Filed under: Java on 2023-09-17 06:53:46

// Program to explain the following StringBuffer function :
// StringBuffer replace( int startIndex, int endIndex, String str )

class  Mreplace1
{
public static void main( String args[ ] )
{
 StringBuffer sb = new StringBuffer( "Java Programming Examples." );

 System.out.println( " String = " + sb );
 
 sb = sb.replace( 5, 16, "Language" );

 System.out.println( " String = " + sb );
}
}


Output:

String = Java Programming Examples.
String = Java Language Examples.

About Author:
S
Shyam Dubey     View Profile
If you are good in any field. Just share your knowledge with others.