Given a String, say String s = "abcderfh";
How would you turn this into a String Array.
Thank you in Advance.....
Given a String, say String s = "abcderfh";
How would you turn this into a String Array.
Thank you in Advance.....
If you mean an array of String, where each element is one letter, do this:
String s = "abcderfh";
String[] letters = s.split("(?<=.)"); // split after every character
System.out.println(Arrays.toString(letters));
Output:
[a, b, c, d, e, r, f, h]
You can find a great example right here: