To convert
String
to char
array in Java, call toCharArray
method.Here's how you do it:
String string = "Hello World!";
char[] charArray = string.toCharArray();
// [H, e, l, l, o, , W, o, r, l, d, !]
System.out.println(java.util.Arrays.toString(charArray));