scala – List , Array

To convert data between the flat world of arrays and the recursive world of lists,you can use method toArray in class List and toList in class Array:

 

object  List_Array extends App{

  val v1=List(1,2)
  val v3=v1.toArray

  val v2=Array(3,4)
  val v4=v2.toList

  println(v3)
  println(v4)
}

[I@77b52d12
List(3, 4)

Leave a comment