Convert String to Array in Java
In Java, you can use the toCharArray() method of String to convert a string into a character array. For example:
String str = "Hello World";
char[] charArray = str.toCharArray();
Additionally, if you want to convert a string into an array of strings based on a specific delimiter, you can use the split() method of the String class. An example is shown below:
String str = "Hello,World";
String[] strArray = str.split(",");
The code above splits the string “Hello,World” into a string array with two elements, [“Hello”, “World”], separated by a comma.