public char[]
toCharArray()
-
将此字符串转换为一个新的字符数组。
-
返回:
-
一个新分配的字符数组,它的长度是此字符串的长度,而且内容被初始化为包含此字符串表示的字符序列。
例如:public class Program{
public static void main(String[] args)
{
String str = "This is a String."; // Convert the above string to a char array.char[] arr = str.toCharArray(); // Display the contents of the char array.System.out.println(arr);
}
}/*
Output:
This is a String. -