Java StringBuffer setCharAt() Example

Java StringBuffer setCharAt(int index, char ch) method - The character at the specified index is set to ch.

Java StringBuffer setCharAt() Example

Example: Example to set character at index 0 with character 'J' using setCharAt() method.
public class SetCharExample {
    public static void main(String[] args) {
        StringBuffer buffer = new StringBuffer("javaguides");
        buffer.setCharAt(0, 'J');
       System.out.println(buffer.toString());
    }
}
Output;
Javaguides

Reference



Comments