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!