+ 2

How to split the letters from a word in a string?

I actually need the answer for a project. Anybody? Or is it impossible?

16th Mar 2020, 1:10 PM
Ayooluwa Aduwo
Ayooluwa Aduwo - avatar
6 Réponses
+ 1
You can create an array of char[] and put the letters in it. String s = "something"; char[] letters = new char[s.length()]; For (int i = 0; i < s.length(); i++) { letters[i] = s.charAt(i); } Or simply: char[] letters = s.toCharArray(); With for loop you can also declare your array as an string array: letters[i] = String.valueOf(s.charAt(i)); But char array saves your memory.
18th Mar 2020, 11:37 AM
Kavoos Salahi
Kavoos Salahi - avatar
+ 1
In Java you can use either- 1) split(); 2) toCharArray();
16th Mar 2020, 1:48 PM
Avinesh
Avinesh - avatar
+ 1
Thanks
18th Mar 2020, 12:10 PM
Ayooluwa Aduwo
Ayooluwa Aduwo - avatar
0
Yes. I am saw something different
16th Mar 2020, 1:43 PM
Ayooluwa Aduwo
Ayooluwa Aduwo - avatar
0
Anytime!
18th Mar 2020, 12:58 PM
Kavoos Salahi
Kavoos Salahi - avatar