Convert string to char array in Java

Java 8Object Oriented ProgrammingProgramming

The following is our string.

String str = "Tutorial";

Now, use the toCharArray() method to convert string to char array.

char[] ch = str.toCharArray();

Now let us see the complete example.


 Live Demo

public class Demo {
   public static void main(String []args) {
      String str = "Tutorial";
      System.out.println("String: "+str);
      char[] ch = str.toCharArray();
      System.out.println("Character Array...");
      for (int i = 0; i < ch.length; i++) {
         System.out.print(ch[i]+" ");


String: Tutorial
Character Array...
T u t o r i a l
Updated on 26-Jun-2020 12:21:40