Iterating over Java collections in Scala

前端 未结 9 1437
不思量自难忘°
不思量自难忘° 2020-11-28 02:19

I\'m writing some Scala code which uses the Apache POI API. I would like to iterate over the rows contained in the java.util.Iterator that I get from the Sheet

9条回答
  •  一生所求
    2020-11-28 02:38

    You could convert the Java collection to an array and use that:

    val array = java.util.Arrays.asList("one","two","three").toArray
    array.foreach(println)
    

    Or go on and convert the array to a Scala list:

    val list = List.fromArray(array)
    

提交回复
热议问题