By "doesn't work" do you mean doesn't compile? If so, check the version of
Java you are using; the for : each syntax is only available from v5.0 up.
If by "doesn't work" you mean something else, can you lease explain what that is (by describing the behaviour and/or posting any stack trace you have)?