Java / Using String
toCharArray() Method
converts the string to a new character array.
public char[] toCharArray()
public class CharArrayExample { public static void main(String args[]) { String myString = new String("JavaPedia.net"); char[] myCharArray = myString.toCharArray(); System.out.println("Length of the Array=" + myCharArray.length); System.out.println(("Element at the first index= " + myCharArray[0])); } }
Output:
Length of the Array=13
Element at the first index= J
More Related questions...