The String.char[] java.lang.String.toCharArray() method converts this string to a new character array.
Java String toCharArray() Method Example
This is a complete example to demonstrate the usage of toCharArray() method.public class ToCharArrayExample {
public static void main(String[] args) {
String str = "javaguides";
char[] characters = str.toCharArray();
for (char c : characters) {
System.out.println(c);
}
}
}
Output:
j a v a g u i d e s
Reference
Free Spring Boot Tutorial - 5 Hours Full Course
Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course