Java StringBuilder getChars() Method Example

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

Java StringBuilder getChars() Method Example

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

Reference


Free Spring Boot Tutorial - 5 Hours Full Course


Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course

Comments