DavidC
0
Q:

java string to char array

char[] a = {'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'};
String str = new String(a);
9
String str = "example";
char[] ch = str.toCharArray(); 
10
import java.util.*; 
  
public class GFG { 
  
    public static void main(String args[]) 
    { 
  
        String str = "GeeksForGeeks"; 
  
        // Creating array and Storing the array 
        // returned by toCharArray() 
        char[] ch = str.toCharArray(); 
  
        // Printing array 
        for (char c : ch) { 
            System.out.println(c); 
        } 
    } 
} 
3
String str = "example";
char[] ch = str.toCharArray();
1

New to Communities?

Join the community