Convert string to char array in Java
Description
The following code shows how to convert string to char array.
Example
/*from w ww . ja v a2 s . c o m*/
public class Main {
public static void main(String[] args) {
String literal = "Examples from java2s.com";
char[] temp = literal.toCharArray();
for (int i = 0; i < temp.length; i++) {
System.out.print(temp[i]);
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »