String to char array example in java?

public class StringToCharArrayExample {

	public static void main(String args[]) {

		String str = "JAVADOCWORLD";

		// declare the char array
		char[] charArray;

		// use toCharArray() method to convert from string to array
		charArray = str.toCharArray();

		// print the array
		for (int index = 0; index < charArray.length; index++)
			System.out.println(charArray[index]);

	}

}
Output
J A V A D O C W O R L D










Related Examples


Write a program to check if an input String is Palindrome or not?
Calculate the factorial of a given number using Java?
How to reverse a number in Java?
Write a program to convert from decimal to binary?
Producer Consumer Example in Thread
Write a program to reverse a String?








Receive Latest Java Examples in Your Email: