java.util.Iterator to Scala list?

前端 未结 5 1641
走了就别回头了
走了就别回头了 2021-02-12 13:16

I have the following code:

private lazy val keys: List[String] = obj.getKeys().asScala.toList

obj.getKeys returns a java.uti

5条回答
  •  礼貌的吻别
    2021-02-12 14:07

    As of scala 2.12.8 one could use

    import scala.collection.JavaConverters._
    
    asScalaIterator(java.util.Iterator variable).toSeq
    

提交回复
热议问题