如何使用val将字符串数组转换为整数列表。我正在使用下面的代码来做到这一点
object ArraytoListobj {
def main(args :Array[String]) {
val intList :List[Int] = args.toList
println(intList)
}
}
Run Code Online (Sandbox Code Playgroud)
尝试编译程序时,出现错误。
scala:3: error: type mismatch;
found : List[String]
required: List[Int]
val intList :List[Int] = args.toList
one error found
Run Code Online (Sandbox Code Playgroud) scala ×1