I can do this:
char n[] = {'a', 'b', 'c', 'd', 'e'};
for (char n2: n)
{
System.out.println(n2);
}
But why not this:
String n = "abcde";
for (char n2: n)
{
System.out.println(n2);
}
I get this error when I try to print characters of string object using the for-each loop:
How can I fix it? Any help is appreciated. Thanks!