Java StringBuffer getChars Example
StringBuffer class getChars method example. This example shows you how to use getChars method.
StringBuffer class getChars method example. This example shows you how to use getChars method.public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
srcBegin - start copying at this offset.
srcEnd - stop copying at this offset.
dst - the array to copy the data into.
dstBegin - offset into dst.
Here is the code
/**
* @(#) GetChars.java
* A class representing getChars method
* @Version 01-May-2008
* @author Rose India Team
*/
public class GetChars {
public static void main(String args[]) {
StringBuffer sb = new StringBuffer("Rose India Tech");
// Declare a new char array:
char[] arr = new char[]{'a','b','c','d','e','f','g'};
// Copy the chars #5 and #10 to arr:
sb.getChars(5,10,arr,1);
System.out.println(arr);
}
} |
-
|