to char array java

Java
String str = "example";
char[] ch = str.toCharArray(); myString.chars().mapToObj(c -> (char) c).collect(Collectors.toList());// getting single character from string..
String str="abcd";

char c=str.toChar(0); 

System.out.println("output is "+c); // output is aimport 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); 
        } 
    } 
} 

Source

Also in Java: