+ 2
string -> array
how do I take an inputed string and turn it into an array of characters? also, how come my code prints "null" for each character that loops? thank you :) https://code.sololearn.com/cm8Zd68FhTbW/?ref=app
6 ответов
+ 4
String to Array:
//use toCharArray() method
char[] name = theName.toCharArray();
for(char n: name){
System.out.println(n);
}
+ 5
char not Char and inside your loop char not String
+ 4
Why null?
String[] name = new String[theName.length()];
This initialize an String array. But it is not filled with values at this time. So you get null in your loop.
+ 4
Your welcome :)
+ 3
thank you so much :)
+ 1
I get the error: "cannot find symbol"