On this java tutorial, we will be discussing on how to convert a String to char array. There would be cases that the source value is a String object and our business requirements is to have a character array derived from the String input, thus this java example source code is made to to show the conversion of a string input to char array. Code is simple, and you might understand that after you go through this tutorial you will find it very easy. And that is site goal to assist you on enhancing your coding skills.

String to char array Conversion source code

This java source code shows how to convert a String to char array. The conversion is done by calling the toCharArray method of String class. This gives an output in character array format

Sample Output in the running the java program to convert String to char array

You might have already noticed that we have printed the contents of our char array in this example. You can go to how to print an array in java article to understand it further.