getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
- Characters are copied from this sequence into the destination character array dst.
public class Main {
public static void main(String args[]) {
StringBuffer buffer = new StringBuffer("hello there");
System.out.printf("buffer = %s\n", buffer.toString());
System.out.printf("Character at 0: %s\nCharacter at 4: %s\n\n", buffer.charAt(0), buffer
.charAt(4));
char charArray[] = new char[buffer.length()];
buffer.getChars(0, buffer.length(), charArray, 0);
System.out.print("The characters are: ");
}
}
Home
Java Book
Essential Classes
Java Book
Essential Classes
StringBuffer:
- Create StringBuffer object
- append
- StringBuffer capacity()
- charAt(int index): get the char at specified index
- delete(int start, int end) and deleteCharAt(int index)
- ensureCapacity( )
- getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
- indexOf(String str)
- lastIndexOf(String str)
- StringBuffer length()
- Insert(): add data in the middle of a StringBuffer
- replace():replace a StringBuffer
- StringBuffer reverse()
- setCharAt(int index, char ch)
- setLength
- substring
- toString():Convert StringBuffer to String