How to convert a java.util.List to a Scala list

前端 未结 5 827
野的像风
野的像风 2020-12-02 08:01

I have this Scala method with below error. Cannot convert into a Scala list.

 def findAllQuestion():List[Question]={
   questionDao.getAllQuestions()
 } 
         


        
5条回答
  •  醉话见心
    2020-12-02 08:59

    import scala.collection.JavaConversions._
    

    will do implicit conversion for you; e.g.:

    var list = new java.util.ArrayList[Int](1,2,3)
    list.foreach{println}
    

提交回复
热议问题