How do I split a String into chars and put those chars in a pre-declared Array? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do I split a String into chars and put those chars in a pre-declared Array?

I had problems with splitting Strings in Java with the split()-method. Is it possible to declare an Array before initializing it through the split()-method? Or ist there another solution for splitting Strings?

7th Mar 2018, 10:35 PM
leokleinchen
1 Answer
+ 7
char [] s = new char [str.length]; s = str.toCharArray();
7th Mar 2018, 10:53 PM
Vukan
Vukan - avatar