StringBuffer setCharAt(int offset, char newChar) Replaces the character at position offset with newChar. : StringBuffer « Utility Classes « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Utility Classes » StringBuffer 
8.8.9.StringBuffer setCharAt(int offset, char newChar) Replaces the character at position offset with newChar.
public class MainClass{
    public static void main(String[] argv){
        StringBuffer sb = new StringBuffer();
        
        sb.append("this is a test");
        
        sb.setCharAt(2,'N');
        System.out.println(sb);
    }
}
thNs is a test
8.8.StringBuffer
8.8.1.Java's StringBuffer and StringBuilder classes represent strings that can be dynamically modified.
8.8.2.StringBuffer provides several versions of the append() method to convert and append other objects and primitive data types to StringBuffer objects.
8.8.3.StringBuffer() Constructs an empty string buffer.
8.8.4.StringBuffer(int capacity) Constructs an empty string buffer with the specified initial capacity.
8.8.5.StringBuffer(String initialString) Constructs a string buffer that initially contains the specified string.
8.8.6.StringBuffer append(String str), StringBuffer append(Object obj)
8.8.7.StringBuffer insert(int offset, String str) Inserts str into the current string buffer at position offset.
8.8.8.StringBuffer reverse() Reverses the characters of the current string buffer.
8.8.9.StringBuffer setCharAt(int offset, char newChar) Replaces the character at position offset with newChar.
8.8.10.StringBuffer setLength(int newLength) Sets the length of the string buffer to newLength.
8.8.11.The StringBuilder class was introduced in 5.0.
8.8.12.String Concatenation the Easy Way
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.