You are here: Home / Topics / Use of setCharAt() method in Java

Use of setCharAt() method in Java

Filed under: Java on 2023-08-23 18:56:33

// Program to explain the following StringBuffer function :
// void setCharAt( int where, char ch )

class  MsetCharAt1
{
public static void main( String args[ ] )
{
 StringBuffer sb1 = new StringBuffer( "Java Nrogramming Examples." );
 System.out.println( " String Before Replacing = " + sb1 );
 
 sb1.setCharAt( 5, 'P' );

 System.out.println( " String After Replacing  = " + sb1 );
}
}


Output:

String Before Replacing = Java Nrogramming Examples.
String After Replacing  = Java Programming Examples.

About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.