java string tochararray code example
Example 1: Java String toCharArray() method
public class StringToCharArrayDemo
{
public static void main(String[] args)
{
String strInput = new String("Flower Brackets");
char[] chArray = strInput.toCharArray();
System.out.println("Character array: ");
for(char ch : chArray)
{
System.out.println(ch);
}
}
}
Example 2: char array in java
char[] JavaCharArray = new char[5];
JavaCharArray[0] = 'r';
JavaCharArray[1] = 's';
JavaCharArray[2] = 't';
JavaCharArray[3] = 'u';