Java StringBuffer setCharAt Example

StringBuffer class setCharAt method example. This example shows you how to use setCharAt method.


StringBuffer class setCharAt method example. This example shows you how to use setCharAt method.The character at the specified index is set to ch. This sequence is altered to represent a new character sequence that is identical to the old character sequence, except that it contains the character ch at position index.

Here is the code
/**
 * @(#) SetCharAt. java
 * A class representing setCharAt method
 * @Version  01-May-2008
 @author   Rose India Team
 */
 
 public class SetCharAt{
    public static void main(String[] args){

        StringBuffer s = new StringBuffer("Hello world!");

        // Change w to W:
        s.setCharAt(6,'W');

        System.out.println(s);
    }
}

null

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US