public class Program { public static void main(String[] args) { String str = "This is a String.";
// Convert the above string to a char array. char[] arr = str.toCharArray();
// Display the contents of the char array. System.out.println(arr); } }
public class ToCharArrayString {
public static void main(String args[]) {
//method converts complete String value to char array type value
String str = " einstein relativity concept is still a concept of great discussion";
char heram[] = str.toCharArray();
// complete String str value is been converted in to char array data by
// the method
System.out.print("Converted value from String to char array is:
");
System.out.println(heram);
}
}
Output of the program:- Converted value from String to char array is: einstein relativity concept is still a concept of great discussion