Write a Java program to create a character array containing the contents of a string.

Java Programming Language / String in java

1927

Program:

public class Exercise {

  public static void main(String[] args)
    {
        String str = "Java Exercises.";

        // Convert the above string to a char array.
        char[] arr = str.toCharArray();

        // Display the contents of the char array.
        System.out.println(arr);
    }
}

Output:

Java Exercises.
Press any key to continue . . .

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.