How to convert String to char array in Java
Example of converting String to char array in Java

* Convert String to char array example. Program to convert String object
* to array of character.

public class StringToCharArray {

public static void main(String args[]){

String str = "work play";

//to convert string to char array, use toCharArray method of String
char[] ch = str.toCharArray();

System.out.println("String converted to char array");

//print char array
for(int i=0; i< ch.length; i++)
System.out.print(ch[i] + " ");

Ads by Google

String converted to char array
w o r k p l a y
String Examples