Code for Program to show an example of creating Character Arrays from String objects in Java
publicclass JAVA_054
{
publicstaticvoid main(String[] args)
{
String Str="To be or not to be";
char[] cArray_1=Str.toCharArray( );
char[] cArray_2=newchar[6];
Str.getChars(9,15,cArray_2,0);
System.out.println("The String is : " + Str);
System.out.println("The character Array-1 is : ");
for(int i=0;i<cArray_1.length;i++)
System.out.println(cArray_1[i]);
System.out.println("The character Array-2 is : ");
for(int j=0;j<cArray_2.length;j++)
System.out.println(cArray_2[j]);
}
}