toCharArray(); code example
Example 1: Java String toCharArray() method
// String toCharArray() method example or string to char array java
public class StringToCharArrayDemo
{
public static void main(String[] args)
{
String strInput = new String("Flower Brackets");
// using toCharArray() method java
char[] chArray = strInput.toCharArray();
System.out.println("Character array: ");
for(char ch : chArray)
{
System.out.println(ch);
}
}
}
Example 2: tochararray in javascript
// there is not toCharArray() function in javascript ..
// if you want to split string into char array .. then do this method..
let name="hello";
let charArray=name.split(''); // this split string into char ..
console.log(charArray); // output: ['h','e','l','l','o']