Java String.toCharArray()
Syntax
String.toCharArray() has the following syntax.
public char[] toCharArray()
Example
In the following code shows how to use String.toCharArray() method.
import java.util.Arrays;
/*from w w w . j a va 2 s .co m*/
public class Main {
public static void main(String[] argv) {
String str = "java2s.com";
char[] chars = str.toCharArray();
System.out.println(Arrays.toString(chars));
}
}
The output: