toCharArray() 方法将字符串转换为字符数组。
语法:
public char[] toCharArray()
返回值:
字符数组
实例:
public class Test {
public static void main(String args[]) {
String Str = new String("hello,world!");
System.out.print("返回值 :" );
System.out.println( Str.toCharArray() );
}
}运行结果:
返回值 :hello,world!
本文介绍了一个简单的Java示例,展示了如何使用toCharArray()方法将字符串转换成字符数组。通过一个具体的例子,演示了该方法的具体用法及输出结果。
1563

被折叠的 条评论
为什么被折叠?



