Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java toCharArray() Method

Java toCharArray() Method

Java String ClassJava String class


The toCharArray() method converts the string into a character array.

Syntax


public char[] toCharArray()

Parameters

Return Value

The character array.

Example


public class Test {
    public static void main(String args[]) {
        String Str = new String("www.runoob.com");

        System.out.print("返回值 :" );
        System.out.println( Str.toCharArray() );
    }
}

The execution result of the above program is:

返回值 :www.runoob.com

Java String ClassJava String class