如何将java.util.List转换为Scala列表
我有这个错误的Scala方法。 无法转换成Scala列表。
def findAllQuestion():List[Question]={ questionDao.getAllQuestions() }  types不匹配; 发现: java.util.List[com.aitrich.learnware.model.domain.entity.Question] required: scala.collection.immutable.List[com.aitrich.learnware.model.domain.entity.Question] 
 import scala.collection.JavaConversions._ 
会为你做隐式转换; 例如:
 var list = new java.util.ArrayList[Int](1,2,3) list.foreach{println} 
 您可以简单地使用Scala的JavaConverters转换List: 
 import scala.collection.JavaConverters._ def findAllQuestion():List[Question] = { questionDao.getAllQuestions().asScala } 
 def findAllStudentTest(): List[StudentTest] = { studentTestDao.getAllStudentTests().asScala.toList } 
 导入JavaConverters , JavaConverters的响应丢失toList 
 import scala.collection.JavaConverters._ def findAllQuestion():List[Question] = { // java.util.List -> Buffer -> List questionDao.getAllQuestions().asScala.toList }