Java toCharArray() 方法
toCharArray() 方法将字符串转换为字符数组。
语法
public char[] toCharArray()
参数
-
无
返回值
字符数组。
实例
public class Test {
public static void main(String args[]) {
String Str = new String("www.runoob.com");
System.out.print("返回值 :" );
System.out.println( Str.toCharArray() );
}
}
以上程序执行结果为:
返回值 :www.runoob.com
本文详细介绍了Java中String类的toCharArray()方法,该方法用于将字符串转换为字符数组,提供了一个简单的示例程序来展示其用法。
Java String类
2万+

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



