Java String toCharArray() Method
Example
Convert a string to a char
array:
String myStr = "Hello";
char[] myArray = myStr.toCharArray();
System.out.println(myArray[0]);
Definition and Usage
The toCharArray()
method returns a new char
array representing the contents of the string.
Syntax
public char[] toCharArray()
Technical Details
Java version: | Any |
---|
❮ String Methods