Export (0) Print
Expand All
Expand Minimize

java.lang.String.toCharArray()

Visual Studio 2005

Creates a character array containing the contents of the String.


public char[] toCharArray()

A character array containing the contents of the String.

// string_tochararray.jsl

public class Program
{
    public static void main(String[] args)
    {
        String str = "This is a String.";

        // Convert the above string to a char array.
        char[] arr = str.toCharArray();

        // Display the contents of the char array.
        System.out.println(arr);
    }
}

/*
Output:
This is a String.
*/

Community Additions

ADD
Show:
© 2015 Microsoft