Java String toCharArray() method

Let’s learn java String toCharArray() method.

java String toCharArray() method

Java String toCharArray() method

String toCharArray() method converts a string to a new character array.


public char[] toCharArray()


a newly allocated character array whose length is the length of this string and whose contents are initialized to contain the character sequence represented by this string.

Also read – java overview

Let’s see a java program,

public class StringToCharArrayDemo
   public static void main(String[] args)
      String strOriginal = "Flower Brackets";
      // using toCharArray() method java
      char arr[] = strOriginal.toCharArray();
      System.out.println("Character array : ");
      for(char ch : arr)


Character array : Flower Brackets