Get char array from String

Complete source code below will show you, how to get char array from a String. This char array we will store all characters in the String include white space.

**************************************************************************
COMPLETE SOURCE CODE FOR : GetCharArrayFromString.java
**************************************************************************


public class GetCharArrayFromString
{
public static void main(String[]args)
{
//Create a String that we want to get character from it
//You can try other String that you want
String a="Get char array from String.........";

//Create an array from type char that will store all characters from String
//Method toCharArray() will get all characters in the String
char[]storeAllStringCharacter=a.toCharArray();

//Print number of characters in char array
System.out.println("Number of characters in char array is : "+storeAllStringCharacter.length+"\n\n");

//Print all character in char array include their index in String
System.out.println("*******************************");
System.out.println("THE CHARACTER IS : ");
System.out.println("*******************************");
System.out.println();

for(int i=0; i<storeAllStringCharacter.length; i++)
{
System.out.println("Character at index "+i+" in the String is : "+storeAllStringCharacter[i]);
}
}
}


**************************************************************************
JUST COMPILE AND EXECUTE IT
**************************************************************************

RELAXING NATURE VIDEO