Java StringBuffer getChars() Example

Java StringBuffer getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) method - Characters are copied from this sequence into the destination character array dst.

Java StringBuffer getChars() Example

Example: Example to copy characters from this sequence into the destination character array dst.
public class GetCharsExample {
    public static void main(String[] args) {
        StringBuffer buffer = new StringBuffer("javaguides");
        char[] dst = new char[buffer.length()];
        buffer.getChars(0, buffer.length(), dst, 0);
  
        for (char c : dst) {
            System.out.println(c);
        }
    }
}
Output:
j
a
v
a
g
u
i
d
e
s

Reference


Comments