Scala println Array

1.To print a 1-D Array

scala> val a = Array.range(1,10)
a: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> println(a.mkString(" "))
1 2 3 4 5 6 7 8 9

2.To print a 2-D Array

scala> val array = Array.fill(2,2)(0)
array: Array[Array[Int]] = Array(Array(0, 0), Array(0, 0))

scala> println(array.deep.mkString("\n"))
Array(0, 0)
Array(0, 0)

scala> println(array.map(_.mkString(" ")).mkString("\n"))
0 0
0 0

 
  

http://stackoverflow.com/questions/3328085/scala-printing-arrays

你可能感兴趣的:(Scala println Array)