FaltuTech.Club : Fane of Advanced Logical Thriving Utopian Technical Club

Convert a String to Array of Char in Java

Convert a String to Array of Char in Java



class StringToChar{
    public static void main(String args[]){
	String str = new String("HELLO HOW ARE YOU");

	char ch[] = new char[str.length()];

	for(int i=0;i

Discussion

In above code sample we have used str.length() where length() is a function but for array length we use array.length where length is property.