As there are lot of different ways to use the for loop compared to Java. Ill try to post my own examples and the book examples.
Simple Java's for-each could be in Scala
GeSHi (java):
scala> val list = 12 :: 32 :: 4 :: 4 :: Nil
scala> for (i <- list) println(i)
Created by GeSHI 1.0.7.20
Result :
12
32
4
4
You can filter the results
GeSHi (java):
scala> for (i <- list; if i < 5) println(i)
Created by GeSHI 1.0.7.20
Result:
4
4