跳到主要内容

Java toCharArray() 方法


toCharArray() 方法将字符串转换为字符数组。

语法

public char[] toCharArray()

参数

返回值

字符数组。

实例

public class Test {

public static void main(String args[]) {

    String Str = new String("www.lectcode.com");



System.out.print("返回值 :" );

System.out.println( Str.toCharArray() );

    }

}

以上程序执行结果为:

返回值 :www.lectcode.com