java tutorial - How to Convert String to Character Array - java programming - learn java - java basics - java for beginners



 string to char array

Learn javascript - javascript tutorial - string to char array - javascript examples - javascript programs

String to Character Array:

  • The java string to CharArray() method converts string into character array.
  • It returns a newly created character array, its length is similar to this string and its contents are initialized with the characters of this string.String toCharArray returns an array of char, what you have is an array of Character

Sample Code:

public class StringToCharacterArray{
    public static void main(String args[]){
        String str = "wikitechy";
        char[] str_array;
        str_array = str.toCharArray();
        for(int i=0; i< str_array.length; i++)
            System.out.print(str_array[i]);
    }

Output:

         wikitechy

Related Searches to How to Convert String to Character Array