use java foreach
Merge pull request #32 from wingyplus/refactor_loop

use java foreach