English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
La méthode toCharArray() de String en Java convertit une chaîne en tableau de caractères et le renvoie.
The syntax of the toCharArray() method is:
string.toCharArray(int startIndex, int endIndex)
In this case, string is an object of the String class.
Without any parameters
Return a char array
class Main { public static void main(String[] args) { String str = "Java Programming"; //Create a char array char[] result; result = str.toCharArray(); System.out.println(result); // Java Programming {} {}
In this case, the length of the char array result (result) will be equal to the length of the string str.