convert string to string array code example
Example 1: how to convert string to array in java
How to convert string to array
import java.util.*;
public class GFG {
public static void main(String args[])
{
String str = "GeeksForGeeks";
char[] ch = str.toCharArray();
for (char c : ch) {
System.out.println(c);
}
}
}
Example 2: turn array into string
const elements = ['Fire', 'Air', 'Water'];
console.log(elements.join());
console.log(elements.join(''));
console.log(elements.join('-'));
Example 3: how to convert a sentence into string array in java
String str = "This is a simple sentence";
String[] strgs = str.split(" ");
Example 4: how to convert string into string array
public static void main(String[] args) {
String str = "abcdef";
String [] array = str.split("");
}