数组:
数组的值可以改变但是数组的名不能改变:
eg:
scala> val gg = Array("ssss","ddddd")(数组的定义)
scala>val grre = Array(1,2,3)
scala> grre
res12: Array[Int] = Array(1, 2, 3)
scala> grre = gg
<console>:9: error: reassignment to val
grre = gg
^
scala> grre
res13: Array[Int] = Array(1, 2, 3)
List:列表的值一旦被定义了就不能改变,且值的类型必须相同
scala>val lis = List(1,3,2)
scala> lis
res14: List[Int] = List(1, 3, 2)
时间: 2024-11-07 03:36:46