Using a Scanner object in a foreach loop
807589Sep 29 2008 — edited Sep 29 2008Hi,
I am trying to get this code to work:
String numbers = "45 63 123 4 666";
Scanner scan = new Scanner (numbers);
for (String word : scan)
System.out.println(word);
And I am getting the following error from the compiler:
"foreach not applicable to expression types"
I'm not sure why this is causing a problem. Any enlightenment would be greatly appreciated!
Thanks,
Diane Mega